Trait Decode

Source
pub trait Decode: Sized {
    type Error: From<Error>;

    // Required method
    fn decode(reader: &mut impl Reader) -> Result<Self, Self::Error>;
}
Expand description

Decoding trait.

This trait describes how to decode a given type.

Required Associated Types§

Source

type Error: From<Error>

Type returned in the event of a decoding error.

Required Methods§

Source

fn decode(reader: &mut impl Reader) -> Result<Self, Self::Error>

Attempt to decode a value of this type using the provided Reader.

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 Decode for CertType

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<CertType, Error>

Source§

impl Decode for KeypairData

Source§

impl Decode for KeyData

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<KeyData, Error>

Source§

impl Decode for bool

Decode a boolean as described in RFC4251 § 5:

A boolean value is stored as a single byte. The value 0 represents FALSE, and the value 1 represents TRUE. All non-zero values MUST be interpreted as TRUE; however, applications MUST NOT store values other than 0 and 1.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<bool, Error>

Source§

impl Decode for u8

Decode a single byte from the input data.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<u8, Error>

Source§

impl Decode for u32

Decode a uint32 as described in RFC4251 § 5:

Represents a 32-bit unsigned integer. Stored as four bytes in the order of decreasing significance (network byte order). For example: the value 699921578 (0x29b7f4aa) is stored as 29 b7 f4 aa.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<u32, Error>

Source§

impl Decode for u64

Decode a uint64 as described in RFC4251 § 5:

Represents a 64-bit unsigned integer. Stored as eight bytes in the order of decreasing significance (network byte order).

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<u64, Error>

Source§

impl Decode for usize

Decode a usize.

Uses Decode impl on u32 and then converts to a usize, handling potential overflow if usize is smaller than u32.

Enforces a library-internal limit of 1048575, as the main use case for usize is length prefixes.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<usize, Error>

Source§

impl Decode for String

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<String, Error>

Source§

impl Decode for Vec<u8>

Decodes Vec<u8> from string as described in RFC4251 § 5:

Arbitrary length binary string. Strings are allowed to contain arbitrary binary data, including null characters and 8-bit characters. They are stored as a uint32 containing its length (number of bytes that follow) and zero (= empty string) or more bytes that are the value of the string. Terminating null characters are not used.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<Vec<u8>, Error>

Source§

impl Decode for Vec<String>

Decodes Vec<String> from name-list as described in RFC4251 § 5:

A string containing a comma-separated list of names. A name-list is represented as a uint32 containing its length (number of bytes that follow) followed by a comma-separated list of zero or more names. A name MUST have a non-zero length, and it MUST NOT contain a comma (“,”). As this is a list of names, all of the elements contained are names and MUST be in US-ASCII. Context may impose additional restrictions on the names. For example, the names in a name-list may have to be a list of valid algorithm identifiers (see Section 6 below), or a list of RFC3066 language tags. The order of the names in a name-list may or may not be significant. Again, this depends on the context in which the list is used. Terminating null characters MUST NOT be used, neither for the individual names, nor for the list as a whole.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<Vec<String>, Error>

Source§

impl Decode for OptionsMap

Source§

impl Decode for Comment

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<Comment, Error>

Source§

impl Decode for DsaKeypair

Source§

impl Decode for DsaPrivateKey

Source§

impl Decode for Ed25519Keypair

Source§

impl Decode for OpaqueKeypairBytes

Source§

impl Decode for OpaquePrivateKeyBytes

Source§

impl Decode for RsaKeypair

Source§

impl Decode for RsaPrivateKey

Source§

impl Decode for SkEd25519

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<SkEd25519, Error>

Source§

impl Decode for DsaPublicKey

Source§

impl Decode for Ed25519PublicKey

Source§

impl Decode for OpaquePublicKeyBytes

Source§

impl Decode for RsaPublicKey

Source§

impl Decode for SkEd25519

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<SkEd25519, Error>

Source§

impl Decode for SshSig

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<SshSig, Error>

Source§

impl<const N: usize> Decode for [u8; N]

Decodes a byte array from byte[n] as described in RFC4251 § 5:

A byte represents an arbitrary 8-bit value (octet). Fixed length data is sometimes represented as an array of bytes, written byte[n], where n is the number of bytes in the array.

Note that unlike string, this type is encoded without a length prefix, but instead implicitly obtains its length as N.

Source§

type Error = Error

Source§

fn decode(reader: &mut impl Reader) -> Result<[u8; N], Error>

Implementors§