Skip to content

Commit 88cf117

Browse files
ahmedcharlesrjzak
authored andcommitted
refactor: remove unnecessary bounds from types
This will allow future changes to enable zero copy deserialization to avoid more complicated bounds on various types. Signed-off-by: Ahmed Charles <[email protected]>
1 parent 9299517 commit 88cf117

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

ciborium-ll/src/dec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<T> From<T> for Error<T> {
2828
/// This decoder manages the low-level decoding of CBOR items into `Header`
2929
/// objects. It also contains utility functions for parsing segmented bytes
3030
/// and text inputs.
31-
pub struct Decoder<R: Read> {
31+
pub struct Decoder<R> {
3232
reader: R,
3333
offset: usize,
3434
buffer: Option<Title>,

ciborium-ll/src/enc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ciborium_io::Write;
66
///
77
/// This structure wraps a writer and provides convenience functions for
88
/// writing `Header` objects to the wire.
9-
pub struct Encoder<W: Write>(W);
9+
pub struct Encoder<W>(W);
1010

1111
impl<W: Write> From<W> for Encoder<W> {
1212
#[inline]

ciborium-ll/src/seg.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl Parser for Text {
111111
///
112112
/// This type represents a single bytes or text segment on the wire. It can be
113113
/// read out in parsed chunks based on the size of the input scratch buffer.
114-
pub struct Segment<'r, R: Read, P: Parser> {
114+
pub struct Segment<'r, R, P> {
115115
reader: &'r mut Decoder<R>,
116116
unread: usize,
117117
offset: usize,
@@ -169,14 +169,14 @@ enum State {
169169
///
170170
/// CBOR allows for bytes or text items to be segmented. This type represents
171171
/// the state of that segmented input stream.
172-
pub struct Segments<'r, R: Read, P: Parser> {
172+
pub struct Segments<'r, R, P> {
173173
reader: &'r mut Decoder<R>,
174174
state: State,
175175
parser: PhantomData<P>,
176176
unwrap: fn(Header) -> Result<Option<usize>, ()>,
177177
}
178178

179-
impl<'r, R: Read, P: Parser> Segments<'r, R, P> {
179+
impl<'r, R, P> Segments<'r, R, P> {
180180
#[inline]
181181
pub(crate) fn new(
182182
decoder: &'r mut Decoder<R>,
@@ -189,7 +189,9 @@ impl<'r, R: Read, P: Parser> Segments<'r, R, P> {
189189
unwrap,
190190
}
191191
}
192+
}
192193

194+
impl<'r, R: Read, P: Parser> Segments<'r, R, P> {
193195
/// Gets the next segment in the stream
194196
///
195197
/// Returns `Ok(None)` at the conclusion of the stream.

ciborium/src/de/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<E: de::Error> Expected<E> for Header {
4949
}
5050

5151
/// Deserializer
52-
pub struct Deserializer<'b, R: Read> {
52+
pub struct Deserializer<'b, R> {
5353
decoder: Decoder<R>,
5454
scratch: &'b mut [u8],
5555
recurse: usize,
@@ -634,7 +634,7 @@ where
634634
}
635635
}
636636

637-
struct Access<'a, 'b, R: Read>(&'a mut Deserializer<'b, R>, Option<usize>);
637+
struct Access<'a, 'b, R>(&'a mut Deserializer<'b, R>, Option<usize>);
638638

639639
impl<'de, 'a, 'b, R: Read> de::SeqAccess<'de> for Access<'a, 'b, R>
640640
where
@@ -757,7 +757,7 @@ where
757757
}
758758
}
759759

760-
struct BytesAccess<R: Read>(usize, Vec<u8>, core::marker::PhantomData<R>);
760+
struct BytesAccess<R>(usize, Vec<u8>, core::marker::PhantomData<R>);
761761

762762
impl<'de, R: Read> de::SeqAccess<'de> for BytesAccess<R>
763763
where
@@ -787,7 +787,7 @@ where
787787
}
788788
}
789789

790-
struct TagAccess<'a, 'b, R: Read>(&'a mut Deserializer<'b, R>, usize);
790+
struct TagAccess<'a, 'b, R>(&'a mut Deserializer<'b, R>, usize);
791791

792792
impl<'de, 'a, 'b, R: Read> de::Deserializer<'de> for &mut TagAccess<'a, 'b, R>
793793
where

ciborium/src/ser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use ciborium_io::Write;
1212
use ciborium_ll::*;
1313
use serde::{ser, Serialize as _};
1414

15-
struct Serializer<W: Write>(Encoder<W>);
15+
struct Serializer<W>(Encoder<W>);
1616

1717
impl<W: Write> From<W> for Serializer<W> {
1818
#[inline]
@@ -335,7 +335,7 @@ macro_rules! end {
335335
};
336336
}
337337

338-
struct CollectionSerializer<'a, W: Write> {
338+
struct CollectionSerializer<'a, W> {
339339
encoder: &'a mut Serializer<W>,
340340
ending: bool,
341341
tag: bool,

0 commit comments

Comments
 (0)