Trait yasna::BERDecodable[][src]

pub trait BERDecodable: Sized {
    fn decode_ber<'a, 'b>(reader: BERReader<'a, 'b>) -> ASN1Result<Self>;
}

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

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);
}
Loading content...

Implementations on Foreign Types

impl<T> BERDecodable for Vec<T> where
    T: BERDecodable
[src]

impl BERDecodable for i64[src]

impl BERDecodable for u64[src]

impl BERDecodable for i32[src]

impl BERDecodable for u32[src]

impl BERDecodable for i16[src]

impl BERDecodable for u16[src]

impl BERDecodable for bool[src]

impl BERDecodable for Vec<u8>[src]

impl BERDecodable for String[src]

impl BERDecodable for ()[src]

impl<T0> BERDecodable for (T0,) where
    T0: BERDecodable
[src]

impl<T0, T1> BERDecodable for (T0, T1) where
    T0: BERDecodable,
    T1: BERDecodable
[src]

impl<T0, T1, T2> BERDecodable for (T0, T1, T2) where
    T0: BERDecodable,
    T1: BERDecodable,
    T2: BERDecodable
[src]

impl<T0, T1, T2, T3> BERDecodable for (T0, T1, T2, T3) where
    T0: BERDecodable,
    T1: BERDecodable,
    T2: BERDecodable,
    T3: BERDecodable
[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]

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]

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]

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]

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]

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]

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]

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]

Loading content...

Implementors

impl BERDecodable for GeneralizedTime[src]

impl BERDecodable for ObjectIdentifier[src]

impl BERDecodable for TaggedDerValue[src]

impl BERDecodable for UTCTime[src]

Loading content...