rasn/
cer.rs

1//! # Canonical Encoding Rules
2
3/// Attempts to decode `T` from `input` using CER.
4pub fn decode<T: crate::Decode>(input: &[u8]) -> Result<T, crate::error::DecodeError> {
5    T::decode(&mut crate::ber::de::Decoder::new(
6        input,
7        crate::ber::de::DecoderOptions::cer(),
8    ))
9}
10
11/// Attempts to encode `value` to CER.
12pub fn encode<T: crate::Encode>(
13    value: &T,
14) -> Result<alloc::vec::Vec<u8>, crate::error::EncodeError> {
15    let mut enc = crate::ber::enc::Encoder::new(crate::ber::enc::EncoderOptions::cer());
16
17    value.encode(&mut enc)?;
18
19    Ok(enc.output())
20}