From fe4e2e27d6a94d106a50e9df85d13eb7ca0e37f4 Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Thu, 5 Dec 2024 00:28:43 +0000 Subject: [PATCH] refactor: deprecate into_vec in favour of to_vec Signed-off-by: Liam Gray --- .github/workflows/test.yml | 1 - ciborium-ll/src/enc.rs | 5 ++++- ciborium-ll/src/hdr.rs | 2 ++ ciborium/src/ser/error.rs | 2 +- ciborium/src/ser/mod.rs | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e5f48a..15fd29c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,6 @@ jobs: - {name: ciborium-ll} - {name: ciborium} - {name: ciborium, feat: std} - - {name: ciborium, feat: canonical} - {name: ciborium-io} - {name: ciborium-io, feat: alloc} - {name: ciborium-io, feat: std} diff --git a/ciborium-ll/src/enc.rs b/ciborium-ll/src/enc.rs index 660f96e..5b30f69 100644 --- a/ciborium-ll/src/enc.rs +++ b/ciborium-ll/src/enc.rs @@ -18,10 +18,12 @@ impl From for Encoder { impl Write for Encoder { type Error = W::Error; + #[inline] fn write_all(&mut self, data: &[u8]) -> Result<(), Self::Error> { self.0.write_all(data) } + #[inline] fn flush(&mut self) -> Result<(), Self::Error> { self.0.flush() } @@ -29,12 +31,13 @@ impl Write for Encoder { impl Encoder { /// Unwraps the `Write`, consuming the `Encoder`. + #[inline] pub fn into_inner(self) -> W { self.0 } /// Push a `Header` to the wire - #[inline] + #[inline(always)] pub fn push(&mut self, header: Header) -> Result<(), W::Error> { let title = Title::from(header); diff --git a/ciborium-ll/src/hdr.rs b/ciborium-ll/src/hdr.rs index dec1788..b6dcac2 100644 --- a/ciborium-ll/src/hdr.rs +++ b/ciborium-ll/src/hdr.rs @@ -75,6 +75,7 @@ pub enum Header { impl TryFrom for Header { type Error = InvalidError; + #[inline] fn try_from(title: Title) -> Result<Self, Self::Error> { let opt = |minor| { Some(match minor { @@ -116,6 +117,7 @@ impl TryFrom<Title> for Header { } impl From<Header> for Title { + #[inline(always)] fn from(header: Header) -> Self { let int = |i: u64| match i { x if x <= 23 => Minor::This(i as u8), diff --git a/ciborium/src/ser/error.rs b/ciborium/src/ser/error.rs index 7861e3e..2968f92 100644 --- a/ciborium/src/ser/error.rs +++ b/ciborium/src/ser/error.rs @@ -10,7 +10,7 @@ use serde::ser::{Error as SerError, StdError}; pub enum Error<T> { /// An error occurred while writing bytes /// - /// Contains the underlying error reaturned while writing. + /// Contains the underlying error returned while writing. Io(T), /// An error indicating a value that cannot be serialized diff --git a/ciborium/src/ser/mod.rs b/ciborium/src/ser/mod.rs index 7fbe31b..4bf393b 100644 --- a/ciborium/src/ser/mod.rs +++ b/ciborium/src/ser/mod.rs @@ -508,7 +508,7 @@ where serializer, collection_type, length, - tag_written: false, + tag_written: !matches!(collection_type, CollectionType::Tag), #[cfg(feature = "std")] cache_keys: Vec::new(), #[cfg(feature = "std")] @@ -645,7 +645,7 @@ where &mut self, value: &U, ) -> Result<(), Self::Error> { - if self.tag_written || !matches!(self.collection_type, CollectionType::Tag) { + if self.tag_written { // untagged tuples are CollectionType::Array to skip writing the tag header return self.inline_serialize_value(value); }