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

Remove usize value from Error::SerializeBufferFull #22

Merged
merged 1 commit into from
Oct 24, 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[Unreleased]: https://github.com/trussed-dev/cbor-smol/compare/0.5.0...HEAD

-
### Changed

- Remove `usize` value from `Error::SerializeBufferFull` variant

## [0.5.0][] - 2024-10-21

Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum Error {
/// This is a feature that cbor-smol intends to support, but does not yet
NotYetImplemented,
/// The serialize buffer is full
SerializeBufferFull(usize),
SerializeBufferFull,
// /// The length of a sequence must be known
// SerializeSeqLengthUnknown,
/// Hit the end of buffer, expected more data
Expand Down Expand Up @@ -78,7 +78,7 @@ impl Display for Error {
NotYetImplemented => {
"This is a feature that cbor-smol intends to support, but does not yet"
}
SerializeBufferFull(i) => "The serialize buffer is full",
SerializeBufferFull => "The serialize buffer is full",
// SerializeSeqLengthUnknown => "The length of a sequence must be known",
DeserializeUnexpectedEnd => "Hit the end of buffer, expected more data",
// DeserializeBadVarint => {
Expand Down
10 changes: 5 additions & 5 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'a> Writer for &'a mut [u8] {
let l = buf.len();
if self.len() < l {
// This buffer will not fit in our slice
return Err(Error::SerializeBufferFull(0));
return Err(Error::SerializeBufferFull);
}
let (current, rem) = mem::take(self).split_at_mut(l);
current.copy_from_slice(buf);
Expand All @@ -34,7 +34,7 @@ impl<const N: usize> Writer for heapless_bytes_v0_3::Bytes<N> {
type Error = Error;
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
self.extend_from_slice(buf)
.or(Err(Error::SerializeBufferFull(self.len())))
.or(Err(Error::SerializeBufferFull))
}
}

Expand All @@ -43,7 +43,7 @@ impl<const N: usize> Writer for heapless_bytes_v0_4::Bytes<N> {
type Error = Error;
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
self.extend_from_slice(buf)
.or(Err(Error::SerializeBufferFull(self.len())))
.or(Err(Error::SerializeBufferFull))
}
}

Expand All @@ -52,7 +52,7 @@ impl<const N: usize> Writer for heapless_v0_7::Vec<u8, N> {
type Error = Error;
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
self.extend_from_slice(buf)
.or(Err(Error::SerializeBufferFull(self.len())))
.or(Err(Error::SerializeBufferFull))
}
}

Expand All @@ -61,7 +61,7 @@ impl<const N: usize> Writer for heapless_v0_8::Vec<u8, N> {
type Error = Error;
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
self.extend_from_slice(buf)
.or(Err(Error::SerializeBufferFull(self.len())))
.or(Err(Error::SerializeBufferFull))
}
}

Expand Down
Loading