pub trait DecodeValue<'a>: Sized {
type Error: Error + From<Error> + 'static;
// Required method
fn decode_value<R>(
reader: &mut R,
header: Header,
) -> Result<Self, Self::Error>
where R: Reader<'a>;
}Expand description
DecodeValue trait parses the value part of a Tag-Length-Value object,
sans the [Tag] and [Length].
As opposed to Decode, implementer is expected to read the inner content only,
without the Header, which was decoded beforehand.
§Example
use der::{Decode, DecodeValue, ErrorKind, FixedTag, Header, Reader, Tag};
/// 1-byte month
struct MyByteMonth(u8);
impl<'a> DecodeValue<'a> for MyByteMonth {
type Error = der::Error;
fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> der::Result<Self> {
let month = reader.read_byte()?;
if (0..12).contains(&month) {
Ok(Self(month))
} else {
Err(reader.error(ErrorKind::DateTime))
}
}
}
impl FixedTag for MyByteMonth {
const TAG: Tag = Tag::OctetString;
}
let month = MyByteMonth::from_der(b"\x04\x01\x09").expect("month to decode");
assert_eq!(month.0, 9);Required Associated Types§
Required Methods§
Sourcefn decode_value<R>(reader: &mut R, header: Header) -> Result<Self, Self::Error>where
R: Reader<'a>,
fn decode_value<R>(reader: &mut R, header: Header) -> Result<Self, Self::Error>where
R: Reader<'a>,
Attempt to decode this value using the provided Reader.
§Errors
Returns Self::Error in the event a decoding error occurred.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a> DecodeValue<'a> for bool
impl<'a> DecodeValue<'a> for bool
Source§impl<'a> DecodeValue<'a> for i8
impl<'a> DecodeValue<'a> for i8
Source§impl<'a> DecodeValue<'a> for i16
impl<'a> DecodeValue<'a> for i16
Source§impl<'a> DecodeValue<'a> for i32
impl<'a> DecodeValue<'a> for i32
Source§impl<'a> DecodeValue<'a> for i64
impl<'a> DecodeValue<'a> for i64
Source§impl<'a> DecodeValue<'a> for i128
impl<'a> DecodeValue<'a> for i128
Source§impl<'a> DecodeValue<'a> for u8
impl<'a> DecodeValue<'a> for u8
Source§impl<'a> DecodeValue<'a> for u16
impl<'a> DecodeValue<'a> for u16
Source§impl<'a> DecodeValue<'a> for u32
impl<'a> DecodeValue<'a> for u32
Source§impl<'a> DecodeValue<'a> for u64
impl<'a> DecodeValue<'a> for u64
Source§impl<'a> DecodeValue<'a> for u128
impl<'a> DecodeValue<'a> for u128
Source§impl<'a> DecodeValue<'a> for ()
impl<'a> DecodeValue<'a> for ()
Source§impl<'a> DecodeValue<'a> for String
Available on crate feature alloc only.
impl<'a> DecodeValue<'a> for String
Available on crate feature
alloc only.Source§impl<'a> DecodeValue<'a> for SystemTime
Available on crate feature std only.
impl<'a> DecodeValue<'a> for SystemTime
Available on crate feature
std only.Source§impl<'a, T> DecodeValue<'a> for Box<T>where
T: DecodeValue<'a>,
Available on crate feature alloc only.
impl<'a, T> DecodeValue<'a> for Box<T>where
T: DecodeValue<'a>,
Available on crate feature
alloc only.Source§impl<'a, T> DecodeValue<'a> for Vec<T>where
T: Decode<'a>,
Available on crate feature alloc only.
impl<'a, T> DecodeValue<'a> for Vec<T>where
T: Decode<'a>,
Available on crate feature
alloc only.Source§impl<'a, T, E> DecodeValue<'a> for Cow<'a, T>where
T: ToOwned + ?Sized,
&'a T: DecodeValue<'a, Error = E>,
<T as ToOwned>::Owned: for<'b> DecodeValue<'b, Error = E>,
E: Error + From<Error> + 'static,
Available on crate feature alloc only.
impl<'a, T, E> DecodeValue<'a> for Cow<'a, T>where
T: ToOwned + ?Sized,
&'a T: DecodeValue<'a, Error = E>,
<T as ToOwned>::Owned: for<'b> DecodeValue<'b, Error = E>,
E: Error + From<Error> + 'static,
Available on crate feature
alloc only.Implementors§
Source§impl<'__der> DecodeValue<'__der> for PrintableString
impl<'__der> DecodeValue<'__der> for PrintableString
Source§impl<'__der> DecodeValue<'__der> for TeletexString
impl<'__der> DecodeValue<'__der> for TeletexString
Source§impl<'__der, 'a> DecodeValue<'__der> for Ia5StringRef<'a>where
'__der: 'a,
impl<'__der, 'a> DecodeValue<'__der> for Ia5StringRef<'a>where
'__der: 'a,
Source§impl<'__der, 'a> DecodeValue<'__der> for PrintableStringRef<'a>where
'__der: 'a,
impl<'__der, 'a> DecodeValue<'__der> for PrintableStringRef<'a>where
'__der: 'a,
Source§impl<'__der, 'a> DecodeValue<'__der> for TeletexStringRef<'a>where
'__der: 'a,
impl<'__der, 'a> DecodeValue<'__der> for TeletexStringRef<'a>where
'__der: 'a,
Source§impl<'__der, 'a> DecodeValue<'__der> for Utf8StringRef<'a>where
'__der: 'a,
impl<'__der, 'a> DecodeValue<'__der> for Utf8StringRef<'a>where
'__der: 'a,
Source§impl<'__der, 'a> DecodeValue<'__der> for VideotexStringRef<'a>where
'__der: 'a,
impl<'__der, 'a> DecodeValue<'__der> for VideotexStringRef<'a>where
'__der: 'a,
Source§impl<'a> DecodeValue<'a> for &'a OctetStringRef
impl<'a> DecodeValue<'a> for &'a OctetStringRef
Source§impl<'a> DecodeValue<'a> for &'a SequenceRef
impl<'a> DecodeValue<'a> for &'a SequenceRef
Source§impl<'a> DecodeValue<'a> for BitStringRef<'a>
impl<'a> DecodeValue<'a> for BitStringRef<'a>
Source§impl<'a> DecodeValue<'a> for GeneralStringRef<'a>
impl<'a> DecodeValue<'a> for GeneralStringRef<'a>
Source§impl<'a> DecodeValue<'a> for GeneralizedTime
impl<'a> DecodeValue<'a> for GeneralizedTime
Source§impl<'a> DecodeValue<'a> for OctetString
impl<'a> DecodeValue<'a> for OctetString
Source§impl<'a, Params> DecodeValue<'a> for AlgorithmIdentifier<Params>
impl<'a, Params> DecodeValue<'a> for AlgorithmIdentifier<Params>
Source§impl<'a, Params, Key> DecodeValue<'a> for SubjectPublicKeyInfo<Params, Key>
impl<'a, Params, Key> DecodeValue<'a> for SubjectPublicKeyInfo<Params, Key>
Source§impl<'a, Params, Key, PubKey> DecodeValue<'a> for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a,
impl<'a, Params, Key, PubKey> DecodeValue<'a> for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a,
Source§impl<'a, T> DecodeValue<'a> for SetOfVec<T>
Available on crate feature alloc only.
impl<'a, T> DecodeValue<'a> for SetOfVec<T>
Available on crate feature
alloc only.