rustls::pki_types::pem

Trait PemObject

Source
pub trait PemObject: Sized {
    // Required method
    fn from_pem(kind: SectionKind, der: Vec<u8>) -> Option<Self>;

    // Provided methods
    fn from_pem_slice(pem: &[u8]) -> Result<Self, Error> { ... }
    fn pem_slice_iter(pem: &[u8]) -> SliceIter<'_, Self>  { ... }
    fn from_pem_file(file_name: impl AsRef<Path>) -> Result<Self, Error> { ... }
    fn pem_file_iter(
        file_name: impl AsRef<Path>,
    ) -> Result<ReadIter<BufReader<File>, Self>, Error> { ... }
    fn from_pem_reader(rd: impl Read) -> Result<Self, Error> { ... }
    fn pem_reader_iter<R>(rd: R) -> ReadIter<BufReader<R>, Self> 
       where R: Read { ... }
}
Available on crate feature alloc only.
Expand description

Items that can be decoded from PEM data.

Required Methods§

Source

fn from_pem(kind: SectionKind, der: Vec<u8>) -> Option<Self>

Conversion from a PEM SectionKind and body data.

This inspects kind, and if it matches this type’s PEM section kind, converts der into this type.

Provided Methods§

Source

fn from_pem_slice(pem: &[u8]) -> Result<Self, Error>

Decode the first section of this type from PEM contained in a byte slice.

Error::NoItemsFound is returned if no such items are found.

Source

fn pem_slice_iter(pem: &[u8]) -> SliceIter<'_, Self>

Iterate over all sections of this type from PEM contained in a byte slice.

Source

fn from_pem_file(file_name: impl AsRef<Path>) -> Result<Self, Error>

Available on crate feature std only.

Decode the first section of this type from the PEM contents of the named file.

Error::NoItemsFound is returned if no such items are found.

Source

fn pem_file_iter( file_name: impl AsRef<Path>, ) -> Result<ReadIter<BufReader<File>, Self>, Error>

Available on crate feature std only.

Iterate over all sections of this type from the PEM contents of the named file.

This reports errors in two phases:

  • errors opening the file are reported from this function directly,
  • errors reading from the file are reported from the returned iterator,
Source

fn from_pem_reader(rd: impl Read) -> Result<Self, Error>

Available on crate feature std only.

Decode the first section of this type from PEM read from an io::Read.

Source

fn pem_reader_iter<R>(rd: R) -> ReadIter<BufReader<R>, Self>
where R: Read,

Available on crate feature std only.

Iterate over all sections of this type from PEM present in an io::Read.

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 PemObject for (SectionKind, Vec<u8>)

Implementors§

Source§

impl PemObject for PrivateKeyDer<'static>

Source§

impl<T> PemObject for T
where T: PemObjectFilter + From<Vec<u8>>,