Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bytes-sgx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Markus Becker
bytes-sgx
Commits
b2efe63c
Commit
b2efe63c
authored
8 years ago
by
Carl Lerche
Browse files
Options
Downloads
Patches
Plain Diff
Get rid of SliceBuf
parent
16b4266c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/buf/mod.rs
+6
-6
6 additions, 6 deletions
src/buf/mod.rs
src/buf/slice.rs
+0
-59
0 additions, 59 deletions
src/buf/slice.rs
src/lib.rs
+0
-2
0 additions, 2 deletions
src/lib.rs
with
6 additions
and
67 deletions
src/buf/mod.rs
+
6
−
6
View file @
b2efe63c
...
@@ -2,14 +2,12 @@ mod append;
...
@@ -2,14 +2,12 @@ mod append;
mod
byte
;
mod
byte
;
mod
ring
;
mod
ring
;
mod
sink
;
mod
sink
;
mod
slice
;
mod
source
;
mod
source
;
mod
take
;
mod
take
;
pub
use
self
::
append
::
AppendBuf
;
pub
use
self
::
append
::
AppendBuf
;
pub
use
self
::
byte
::{
ByteBuf
,
MutByteBuf
,
ROByteBuf
};
pub
use
self
::
byte
::{
ByteBuf
,
MutByteBuf
,
ROByteBuf
};
pub
use
self
::
ring
::
RingBuf
;
pub
use
self
::
ring
::
RingBuf
;
pub
use
self
::
slice
::{
SliceBuf
,
MutSliceBuf
};
pub
use
self
::
take
::
Take
;
pub
use
self
::
take
::
Take
;
use
{
ByteStr
,
RopeBuf
};
use
{
ByteStr
,
RopeBuf
};
...
@@ -43,9 +41,10 @@ pub trait Buf {
...
@@ -43,9 +41,10 @@ pub trait Buf {
/// Returns the number of bytes read.
/// Returns the number of bytes read.
///
///
/// ```
/// ```
/// use bytes::{SliceBuf, Buf};
/// use std::io::Cursor;
/// use bytes::Buf;
///
///
/// let mut buf =
SliceBuf::wrap
(b"hello world");
/// let mut buf =
Cursor::new
(b"hello world");
/// let mut dst = [0; 5];
/// let mut dst = [0; 5];
///
///
/// buf.read_slice(&mut dst);
/// buf.read_slice(&mut dst);
...
@@ -117,12 +116,13 @@ pub trait MutBuf : Sized {
...
@@ -117,12 +116,13 @@ pub trait MutBuf : Sized {
/// Returns the number of bytes written.
/// Returns the number of bytes written.
///
///
/// ```
/// ```
/// use bytes::{MutSliceBuf, Buf, MutBuf};
/// use bytes::MutBuf;
/// use std::io::Cursor;
///
///
/// let mut dst = [0; 6];
/// let mut dst = [0; 6];
///
///
/// {
/// {
/// let mut buf =
MutSliceBuf::wrap
(&mut dst);
/// let mut buf =
Cursor::new
(&mut dst);
/// buf.write_slice(b"hello");
/// buf.write_slice(b"hello");
///
///
/// assert_eq!(1, buf.remaining());
/// assert_eq!(1, buf.remaining());
...
...
This diff is collapsed.
Click to expand it.
src/buf/slice.rs
deleted
100644 → 0
+
0
−
59
View file @
16b4266c
use
std
::
cmp
;
use
{
Buf
,
MutBuf
};
// TODO: Rename -> Cursor. Use as buf for various byte strings
pub
struct
SliceBuf
<
'a
>
{
bytes
:
&
'a
[
u8
],
pos
:
usize
}
impl
<
'a
>
SliceBuf
<
'a
>
{
pub
fn
wrap
(
bytes
:
&
'a
[
u8
])
->
SliceBuf
<
'a
>
{
SliceBuf
{
bytes
:
bytes
,
pos
:
0
}
}
}
impl
<
'a
>
Buf
for
SliceBuf
<
'a
>
{
fn
remaining
(
&
self
)
->
usize
{
self
.bytes
.len
()
-
self
.pos
}
fn
bytes
<
'b
>
(
&
'b
self
)
->
&
'b
[
u8
]
{
&
self
.bytes
[
self
.pos
..
]
}
fn
advance
(
&
mut
self
,
mut
cnt
:
usize
)
{
cnt
=
cmp
::
min
(
cnt
,
self
.remaining
());
self
.pos
+=
cnt
;
}
}
pub
struct
MutSliceBuf
<
'a
>
{
bytes
:
&
'a
mut
[
u8
],
pos
:
usize
}
impl
<
'a
>
MutSliceBuf
<
'a
>
{
pub
fn
wrap
(
bytes
:
&
'a
mut
[
u8
])
->
MutSliceBuf
<
'a
>
{
MutSliceBuf
{
bytes
:
bytes
,
pos
:
0
}
}
}
impl
<
'a
>
MutBuf
for
MutSliceBuf
<
'a
>
{
fn
remaining
(
&
self
)
->
usize
{
self
.bytes
.len
()
-
self
.pos
}
unsafe
fn
advance
(
&
mut
self
,
mut
cnt
:
usize
)
{
cnt
=
cmp
::
min
(
cnt
,
self
.remaining
());
self
.pos
+=
cnt
;
}
unsafe
fn
mut_bytes
<
'b
>
(
&
'b
mut
self
)
->
&
'b
mut
[
u8
]
{
&
mut
self
.bytes
[
self
.pos
..
]
}
}
This diff is collapsed.
Click to expand it.
src/lib.rs
+
0
−
2
View file @
b2efe63c
...
@@ -14,8 +14,6 @@ pub use buf::{
...
@@ -14,8 +14,6 @@ pub use buf::{
MutByteBuf
,
MutByteBuf
,
RingBuf
,
RingBuf
,
ROByteBuf
,
ROByteBuf
,
SliceBuf
,
MutSliceBuf
,
Take
,
Take
,
ReadExt
,
ReadExt
,
WriteExt
,
WriteExt
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment