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

Add missing decode impls (fixes #69) #72

Merged
merged 1 commit into from
Feb 10, 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 crates/musli-common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ macro_rules! encode_with_extensions {
#[doc(hidden)]
#[macro_export]
macro_rules! encoding_from_slice_impls {
($encoder_new:path, $decoder_new:path) => {
($decoder_new:path) => {
/// Decode the given type `T` from the given slice using the current
/// configuration.
#[inline]
Expand Down
19 changes: 2 additions & 17 deletions crates/musli-descriptive/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,8 @@ where
}
}

musli_common::encoding_impls! {
SelfEncoder::<_>::new,
SelfDecoder::new
}

/// Decode the given type `T` from the given slice using the current
/// configuration.
#[inline]
pub fn from_slice<'de, T>(self, bytes: &'de [u8]) -> Result<T, Error>
where
T: Decode<'de, M>,
{
let alloc = musli_common::allocator::Default::default();
let mut cx = musli_common::context::Same::new(&alloc);
let mut reader = SliceReader::new(bytes);
T::decode(&mut cx, SelfDecoder::<_>::new(&mut reader))
}
musli_common::encoding_impls!(SelfEncoder::new, SelfDecoder::new);
musli_common::encoding_from_slice_impls!(SelfDecoder::new);
}

impl<M> Clone for Encoding<M>
Expand Down
14 changes: 5 additions & 9 deletions crates/musli-storage/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,11 @@ where
}
}

musli_common::encoding_impls! {
StorageEncoder::<_, I, L, Error>::new,
StorageDecoder::<_, I, L, Error>::new
}

musli_common::encoding_from_slice_impls! {
StorageEncoder::<_, I, L, Error>::new,
StorageDecoder::<_, I, L, Error>::new
}
musli_common::encoding_impls!(
StorageEncoder::<_, I, L, _>::new,
StorageDecoder::<_, I, L, _>::new
);
musli_common::encoding_from_slice_impls!(StorageDecoder::<_, I, L, _>::new);
}

impl<M, I, L> Clone for Encoding<M, I, L>
Expand Down
11 changes: 2 additions & 9 deletions crates/musli-wire/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,8 @@ where
}
}

musli_common::encoding_impls! {
WireEncoder::<_, I, L>::new,
WireDecoder::<_, I, L>::new
}

musli_common::encoding_from_slice_impls! {
WireEncoder::<_, I, L>::new,
WireDecoder::<_, I, L>::new
}
musli_common::encoding_impls!(WireEncoder::<_, I, L>::new, WireDecoder::<_, I, L>::new);
musli_common::encoding_from_slice_impls!(WireDecoder::<_, I, L>::new);
}

impl<M, I, L> Clone for Encoding<M, I, L>
Expand Down
Loading