Trait yasna::BERDecodable [−][src]
Types decodable in BER.
Examples
use yasna; let asn : i64 = yasna::decode_der(&[2, 3, 0, 255, 255]).unwrap(); assert_eq!(asn, 65535);
Limitations
Rust types don’t correspond to ASN.1 types one-to-one. Not all kinds
of ASN.1 types can be decoded via default BERDecodable
implementation.
If you want to decode ASN.1, you may implement BERDecodable
for your
own types or use parse_der
/parse_ber
.
Default implementations
- The decoder for
Vec<T>
is implemented as SEQUENCE OF decoder. ()
as NULL decoder.- Tuples (except
()
) as SEQUENCE decoder. Vec<u8>
as OCTETSTRING decoder.BitVec
as BITSTRING decoder.String
as UTF8String decoder.i64
,u64
,i32
,u32
,i16
,u16
,BigInt
,BigUint
as INTEGER decoder. (u8
is avoided because of confliction.)bool
as BOOLEAN decoder.ObjectIdentifier
as OBJECTT IDENTIFIER decoder.UTCTime
/GeneralizedTime
as UTCTime/GeneralizedTime decoder.
Required methods
fn decode_ber<'a, 'b>(reader: BERReader<'a, 'b>) -> ASN1Result<Self>
[src]
Reads an ASN.1 value from BERReader
and converts it to Self
.
Examples
use yasna::{BERDecodable,BERReader,ASN1Result}; struct Entry { name: String, age: i64, } impl BERDecodable for Entry { fn decode_ber(reader: BERReader) -> ASN1Result<Self> { reader.read_sequence(|reader| { let name = try!(reader.next().read_visible_string()); let age = try!(reader.next().read_i64()); return Ok(Entry { name: name, age: age, }); }) } } fn main() { let entry : Entry = yasna::decode_der( &[48, 9, 26, 4, 74, 111, 104, 110, 2, 1, 32]).unwrap(); assert_eq!(entry.name, "John"); assert_eq!(entry.age, 32); }
Implementations on Foreign Types
impl<T> BERDecodable for Vec<T> where
T: BERDecodable,
[src]
T: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for i64
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for u64
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for i32
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for u32
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for i16
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for u16
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for bool
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for Vec<u8>
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for String
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl BERDecodable for ()
[src]
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0> BERDecodable for (T0,) where
T0: BERDecodable,
[src]
T0: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1> BERDecodable for (T0, T1) where
T0: BERDecodable,
T1: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2> BERDecodable for (T0, T1, T2) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3> BERDecodable for (T0, T1, T2, T3) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4> BERDecodable for (T0, T1, T2, T3, T4) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5> BERDecodable for (T0, T1, T2, T3, T4, T5) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5, T6> BERDecodable for (T0, T1, T2, T3, T4, T5, T6) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5, T6, T7> BERDecodable for (T0, T1, T2, T3, T4, T5, T6, T7) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> BERDecodable for (T0, T1, T2, T3, T4, T5, T6, T7, T8) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> BERDecodable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
T9: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
T9: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> BERDecodable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
T9: BERDecodable,
T10: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
T9: BERDecodable,
T10: BERDecodable,
fn decode_ber(reader: BERReader<'_, '_>) -> ASN1Result<Self>
[src]
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> BERDecodable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) where
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
T9: BERDecodable,
T10: BERDecodable,
T11: BERDecodable,
[src]
T0: BERDecodable,
T1: BERDecodable,
T2: BERDecodable,
T3: BERDecodable,
T4: BERDecodable,
T5: BERDecodable,
T6: BERDecodable,
T7: BERDecodable,
T8: BERDecodable,
T9: BERDecodable,
T10: BERDecodable,
T11: BERDecodable,