Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unnecessary bounds from types #116

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ciborium-ll/src/dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<T> From<T> for Error<T> {
/// This decoder manages the low-level decoding of CBOR items into `Header`
/// objects. It also contains utility functions for parsing segmented bytes
/// and text inputs.
pub struct Decoder<R: Read> {
pub struct Decoder<R> {
reader: R,
offset: usize,
buffer: Option<Title>,
Expand Down
2 changes: 1 addition & 1 deletion ciborium-ll/src/enc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ciborium_io::Write;
///
/// This structure wraps a writer and provides convenience functions for
/// writing `Header` objects to the wire.
pub struct Encoder<W: Write>(W);
pub struct Encoder<W>(W);

impl<W: Write> From<W> for Encoder<W> {
#[inline]
Expand Down
8 changes: 5 additions & 3 deletions ciborium-ll/src/seg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Parser for Text {
///
/// This type represents a single bytes or text segment on the wire. It can be
/// read out in parsed chunks based on the size of the input scratch buffer.
pub struct Segment<'r, R: Read, P: Parser> {
pub struct Segment<'r, R, P> {
reader: &'r mut Decoder<R>,
unread: usize,
offset: usize,
Expand Down Expand Up @@ -169,14 +169,14 @@ enum State {
///
/// CBOR allows for bytes or text items to be segmented. This type represents
/// the state of that segmented input stream.
pub struct Segments<'r, R: Read, P: Parser> {
pub struct Segments<'r, R, P> {
reader: &'r mut Decoder<R>,
state: State,
parser: PhantomData<P>,
unwrap: fn(Header) -> Result<Option<usize>, ()>,
}

impl<'r, R: Read, P: Parser> Segments<'r, R, P> {
impl<'r, R, P> Segments<'r, R, P> {
#[inline]
pub(crate) fn new(
decoder: &'r mut Decoder<R>,
Expand All @@ -189,7 +189,9 @@ impl<'r, R: Read, P: Parser> Segments<'r, R, P> {
unwrap,
}
}
}

impl<'r, R: Read, P: Parser> Segments<'r, R, P> {
/// Gets the next segment in the stream
///
/// Returns `Ok(None)` at the conclusion of the stream.
Expand Down
8 changes: 4 additions & 4 deletions ciborium/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

pub use error::Error;

use alloc::{string::String, vec::Vec};

Check warning on line 9 in ciborium/src/de/mod.rs

View workflow job for this annotation

GitHub Actions / test nightly debug ciborium std

the item `String` is imported redundantly

Check warning on line 9 in ciborium/src/de/mod.rs

View workflow job for this annotation

GitHub Actions / test nightly debug ciborium std

the item `Vec` is imported redundantly

Check warning on line 9 in ciborium/src/de/mod.rs

View workflow job for this annotation

GitHub Actions / test nightly release ciborium std

the item `String` is imported redundantly

Check warning on line 9 in ciborium/src/de/mod.rs

View workflow job for this annotation

GitHub Actions / test nightly release ciborium std

the item `Vec` is imported redundantly

use ciborium_io::Read;
use ciborium_ll::*;
Expand Down Expand Up @@ -49,7 +49,7 @@
}

/// Deserializer
pub struct Deserializer<'b, R: Read> {
pub struct Deserializer<'b, R> {
decoder: Decoder<R>,
scratch: &'b mut [u8],
recurse: usize,
Expand Down Expand Up @@ -634,7 +634,7 @@
}
}

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

impl<'de, 'a, 'b, R: Read> de::SeqAccess<'de> for Access<'a, 'b, R>
where
Expand Down Expand Up @@ -757,7 +757,7 @@
}
}

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

impl<'de, R: Read> de::SeqAccess<'de> for BytesAccess<R>
where
Expand Down Expand Up @@ -787,7 +787,7 @@
}
}

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

impl<'de, 'a, 'b, R: Read> de::Deserializer<'de> for &mut TagAccess<'a, 'b, R>
where
Expand Down
4 changes: 2 additions & 2 deletions ciborium/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

pub use error::Error;

use alloc::string::ToString;

Check warning on line 9 in ciborium/src/ser/mod.rs

View workflow job for this annotation

GitHub Actions / test nightly debug ciborium std

the item `ToString` is imported redundantly

Check warning on line 9 in ciborium/src/ser/mod.rs

View workflow job for this annotation

GitHub Actions / test nightly release ciborium std

the item `ToString` is imported redundantly

use ciborium_io::Write;
use ciborium_ll::*;
use serde::{ser, Serialize as _};

struct Serializer<W: Write>(Encoder<W>);
struct Serializer<W>(Encoder<W>);

impl<W: Write> From<W> for Serializer<W> {
#[inline]
Expand Down Expand Up @@ -335,7 +335,7 @@
};
}

struct CollectionSerializer<'a, W: Write> {
struct CollectionSerializer<'a, W> {
encoder: &'a mut Serializer<W>,
ending: bool,
tag: bool,
Expand Down
Loading