Trait ssh_encoding::Encode

source ·
pub trait Encode {
    // Required methods
    fn encoded_len(&self) -> Result<usize, Error>;
    fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>;

    // Provided methods
    fn encoded_len_prefixed(&self) -> Result<usize, Error> { ... }
    fn encode_prefixed(&self, writer: &mut impl Writer) -> Result<(), Error> { ... }
}
Expand description

Encoding trait.

This trait describes how to encode a given type.

Required Methods§

source

fn encoded_len(&self) -> Result<usize, Error>

Get the length of this type encoded in bytes, prior to Base64 encoding.

source

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

Encode this value using the provided Writer.

Provided Methods§

source

fn encoded_len_prefixed(&self) -> Result<usize, Error>

Return the length of this type after encoding when prepended with a uint32 length prefix.

source

fn encode_prefixed(&self, writer: &mut impl Writer) -> Result<(), Error>

Encode this value, first prepending a uint32 length prefix set to Encode::encoded_len.

Implementations on Foreign Types§

source§

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

Encodes [u8; N] into 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.

source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for Vec<String>

Available on crate feature alloc only.
source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for [u8]

Encodes [u8] into 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.

source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for &str

Encode a 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.

Strings are also used to store text. In that case, US-ASCII is used for internal names, and ISO-10646 UTF-8 for text that might be displayed to the user. The terminating null character SHOULD NOT normally be stored in the string. For example: the US-ASCII string “testing” is represented as 00 00 00 07 t e s t i n g. The UTF-8 mapping does not alter the encoding of US-ASCII characters.

source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for u32

Encode 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§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for usize

Encode a usize as a uint32 as described in RFC4251 § 5.

Uses Encode impl on u32 after converting from a usize, handling potential overflow if usize is bigger than u32.

source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for u64

Encode 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§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for Bytes

Available on crate feature bytes only.
source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for String

Available on crate feature alloc only.
source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for Vec<u8>

Available on crate feature alloc only.
source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

source§

impl Encode for u8

Encode a single byte to the writer.

source§

fn encoded_len(&self) -> Result<usize, Error>

source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

Implementors§

source§

impl<T: Label> Encode for T