Skip to content

Commit

Permalink
OER: no more BitSlice for general parsing (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicceboy authored Nov 25, 2024
1 parent 63cfa06 commit 211269e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 142 deletions.
10 changes: 2 additions & 8 deletions src/coer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use crate::types::Constraints;
/// # Errors
/// Returns `DecodeError` if `input` is not valid COER encoding specific to the expected type.
pub fn decode<T: crate::Decode>(input: &[u8]) -> Result<T, DecodeError> {
T::decode(&mut Decoder::<0, 0>::new(
crate::types::BitStr::from_slice(input),
de::DecoderOptions::coer(),
))
T::decode(&mut Decoder::<0, 0>::new(input, de::DecoderOptions::coer()))
}
/// Attempts to encode `value` of type `T` to COER.
///
Expand All @@ -33,10 +30,7 @@ pub fn decode_with_constraints<T: crate::Decode>(
input: &[u8],
) -> Result<T, DecodeError> {
T::decode_with_constraints(
&mut Decoder::<0, 0>::new(
crate::types::BitStr::from_slice(input),
de::DecoderOptions::coer(),
),
&mut Decoder::<0, 0>::new(input, de::DecoderOptions::coer()),
constraints,
)
}
Expand Down
10 changes: 2 additions & 8 deletions src/oer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use crate::types::Constraints;
/// # Errors
/// Returns `DecodeError` if `input` is not valid OER encoding specific to the expected type.
pub fn decode<T: crate::Decode>(input: &[u8]) -> Result<T, DecodeError> {
T::decode(&mut Decoder::<0, 0>::new(
crate::types::BitStr::from_slice(input),
de::DecoderOptions::oer(),
))
T::decode(&mut Decoder::<0, 0>::new(input, de::DecoderOptions::oer()))
}
/// Attempts to encode `value` of type `T` to OER.
///
Expand All @@ -38,10 +35,7 @@ pub fn decode_with_constraints<T: crate::Decode>(
input: &[u8],
) -> Result<T, DecodeError> {
T::decode_with_constraints(
&mut Decoder::<0, 0>::new(
crate::types::BitStr::from_slice(input),
de::DecoderOptions::oer(),
),
&mut Decoder::<0, 0>::new(input, de::DecoderOptions::oer()),
constraints,
)
}
Expand Down
Loading

0 comments on commit 211269e

Please sign in to comment.