Struct trust_dns_proto::rr::rdata::sshfp::HEX

source ·
pub struct HEX { /* private fields */ }
Expand description

HEX formatting specific to TLSA and SSHFP encodings

Methods from Deref<Target = Encoding>§

source

pub fn encode_len(&self, len: usize) -> usize

Returns the encoded length of an input of length len

See encode_mut for when to use it.

source

pub fn encode_mut(&self, input: &[u8], output: &mut [u8])

Encodes input in output

Panics

Panics if the output length does not match the result of encode_len for the input length.

Examples
use data_encoding::BASE64;
let input = b"Hello world";
let output = &mut buffer[0 .. BASE64.encode_len(input.len())];
BASE64.encode_mut(input, output);
assert_eq!(output, b"SGVsbG8gd29ybGQ=");
source

pub fn encode_append(&self, input: &[u8], output: &mut String)

Appends the encoding of input to output

Examples
use data_encoding::BASE64;
let input = b"Hello world";
let mut output = "Result: ".to_string();
BASE64.encode_append(input, &mut output);
assert_eq!(output, "Result: SGVsbG8gd29ybGQ=");
Features

Requires the alloc feature.

source

pub fn encode(&self, input: &[u8]) -> String

Returns encoded input

Examples
use data_encoding::BASE64;
assert_eq!(BASE64.encode(b"Hello world"), "SGVsbG8gd29ybGQ=");
Features

Requires the alloc feature.

source

pub fn decode_len(&self, len: usize) -> Result<usize, DecodeError>

Returns the decoded length of an input of length len

See decode_mut for when to use it.

Errors

Returns an error if len is invalid. The error kind is Length and the position is the greatest valid input length.

source

pub fn decode_mut( &self, input: &[u8], output: &mut [u8] ) -> Result<usize, DecodePartial>

Decodes input in output

Returns the length of the decoded output. This length may be smaller than the output length if the input contained padding or ignored characters. The output bytes after the returned length are not initialized and should not be read.

Panics

Panics if the output length does not match the result of decode_len for the input length. Also panics if decode_len fails for the input length.

Errors

Returns an error if input is invalid. See decode for more details. The are two differences though:

  • Length may be returned only if the encoding allows ignored characters, because otherwise this is already checked by decode_len.
  • The read first bytes of the input have been successfully decoded to the written first bytes of the output.
Examples
use data_encoding::BASE64;
let input = b"SGVsbA==byB3b3JsZA==";
let output = &mut buffer[0 .. BASE64.decode_len(input.len()).unwrap()];
let len = BASE64.decode_mut(input, output).unwrap();
assert_eq!(&output[0 .. len], b"Hello world");
source

pub fn decode(&self, input: &[u8]) -> Result<Vec<u8, Global>, DecodeError>

Returns decoded input

Errors

Returns an error if input is invalid. The error kind can be:

  • Length if the input length is invalid. The position is the greatest valid input length.
  • Symbol if the input contains an invalid character. The position is the first invalid character.
  • Trailing if the input has non-zero trailing bits. This is only possible if the encoding checks trailing bits. The position is the first character containing non-zero trailing bits.
  • Padding if the input has an invalid padding length. This is only possible if the encoding uses padding. The position is the first padding character of the first padding of invalid length.
Examples
use data_encoding::BASE64;
assert_eq!(BASE64.decode(b"SGVsbA==byB3b3JsZA==").unwrap(), b"Hello world");
Features

Requires the alloc feature.

source

pub fn bit_width(&self) -> usize

Returns the bit-width

source

pub fn is_canonical(&self) -> bool

Returns whether the encoding is canonical

An encoding is not canonical if one of the following conditions holds:

  • trailing bits are not checked
  • padding is used
  • characters are ignored
  • characters are translated
source

pub fn specification(&self) -> Specification

Returns the encoding specification

Features

Requires the alloc feature.

Trait Implementations§

source§

impl Deref for HEX

§

type Target = Encoding

The resulting type after dereferencing.
source§

fn deref(&self) -> &Encoding

Dereferences the value.
source§

impl LazyStatic for HEX

Auto Trait Implementations§

§

impl RefUnwindSafe for HEX

§

impl Send for HEX

§

impl Sync for HEX

§

impl Unpin for HEX

§

impl UnwindSafe for HEX

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more