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
6f00c611
Commit
6f00c611
authored
10 years ago
by
Florian Hartwig
Committed by
Carl Lerche
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove RingBufReader and RingBufWriter types
parent
113bff22
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib.rs
+1
-1
1 addition, 1 deletion
src/lib.rs
src/ring.rs
+18
-36
18 additions, 36 deletions
src/ring.rs
with
19 additions
and
37 deletions
src/lib.rs
+
1
−
1
View file @
6f00c611
...
...
@@ -6,7 +6,7 @@
pub
use
byte_buf
::{
ByteBuf
,
ROByteBuf
,
MutByteBuf
};
pub
use
byte_str
::{
SeqByteStr
,
SmallByteStr
,
SmallByteStrBuf
};
pub
use
bytes
::
Bytes
;
pub
use
ring
::
{
RingBuf
,
RingBufReader
,
RingBufWriter
}
;
pub
use
ring
::
RingBuf
;
pub
use
rope
::{
Rope
,
RopeBuf
};
pub
use
slice
::{
SliceBuf
,
MutSliceBuf
};
...
...
This diff is collapsed.
Click to expand it.
src/ring.rs
+
18
−
36
View file @
6f00c611
...
...
@@ -52,16 +52,6 @@ impl RingBuf {
self
.cap
}
// Access readable bytes as a Buf
pub
fn
reader
<
'a
>
(
&
'a
mut
self
)
->
RingBufReader
<
'a
>
{
RingBufReader
{
ring
:
self
}
}
// Access writable bytes as a Buf
pub
fn
writer
<
'a
>
(
&
'a
mut
self
)
->
RingBufWriter
<
'a
>
{
RingBufWriter
{
ring
:
self
}
}
fn
read_remaining
(
&
self
)
->
usize
{
self
.len
}
...
...
@@ -141,59 +131,51 @@ impl Drop for RingBuf {
}
}
pub
struct
RingBufReader
<
'a
>
{
ring
:
&
'a
mut
RingBuf
}
impl
<
'a
>
Buf
for
RingBufReader
<
'a
>
{
impl
Buf
for
RingBuf
{
fn
remaining
(
&
self
)
->
usize
{
self
.
ring
.
read_remaining
()
self
.read_remaining
()
}
fn
bytes
<
'b
>
(
&
'b
self
)
->
&
'b
[
u8
]
{
let
mut
to
=
self
.
ring.
pos
+
self
.
ring.
len
;
fn
bytes
(
&
self
)
->
&
[
u8
]
{
let
mut
to
=
self
.pos
+
self
.len
;
if
to
>
self
.
ring.
cap
{
to
=
self
.
ring.
cap
if
to
>
self
.cap
{
to
=
self
.cap
}
&
self
.
ring
.
as_slice
()[
self
.
ring.
pos
..
to
]
&
self
.as_slice
()[
self
.pos
..
to
]
}
fn
advance
(
&
mut
self
,
cnt
:
usize
)
{
self
.
ring
.
advance_reader
(
cnt
)
self
.advance_reader
(
cnt
)
}
}
pub
struct
RingBufWriter
<
'a
>
{
ring
:
&
'a
mut
RingBuf
}
impl
<
'a
>
MutBuf
for
RingBufWriter
<
'a
>
{
impl
MutBuf
for
RingBuf
{
fn
remaining
(
&
self
)
->
usize
{
self
.
ring
.
write_remaining
()
self
.write_remaining
()
}
fn
advance
(
&
mut
self
,
cnt
:
usize
)
{
self
.
ring
.
advance_writer
(
cnt
)
self
.advance_writer
(
cnt
)
}
fn
mut_bytes
<
'b
>
(
&
'b
mut
self
)
->
&
'b
mut
[
u8
]
{
fn
mut_bytes
(
&
mut
self
)
->
&
mut
[
u8
]
{
let
mut
from
;
let
mut
to
;
from
=
self
.
ring.
pos
+
self
.
ring.
len
;
from
%=
self
.
ring.
cap
;
from
=
self
.pos
+
self
.len
;
from
%=
self
.cap
;
to
=
from
+
s
elf
.
remaining
();
to
=
from
+
<
S
elf
as
MutBuf
>
::
remaining
(
&
self
);
if
to
>=
self
.
ring.
cap
{
to
=
self
.
ring.
cap
;
if
to
>=
self
.cap
{
to
=
self
.cap
;
}
&
mut
self
.
ring
.
as_mut_slice
()[
from
..
to
]
&
mut
self
.as_mut_slice
()[
from
..
to
]
}
}
...
...
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