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: Read>(rd: R) -> ReadIter<BufReader<R>, Self> ⓘ { ... }
}展开描述
可从 PEM 数据解码得到的项。
必需方法§
Sourcefn from_pem(kind: SectionKind, der: Vec<u8>) -> Option<Self>
fn from_pem(kind: SectionKind, der: Vec<u8>) -> Option<Self>
从一个 PEM SectionKind 与相应的 body 数据进行转换。
该函数会检查 kind,若与本类型的 PEM section 类型匹配,
则将 der 转换为本类型。
提供方法§
Sourcefn from_pem_slice(pem: &[u8]) -> Result<Self, Error>
fn from_pem_slice(pem: &[u8]) -> Result<Self, Error>
从一段字节切片中的 PEM 数据里,解码出本类型的第一个 section。
若未找到相应的项,则返回 Error::NoItemsFound。
Sourcefn pem_slice_iter(pem: &[u8]) -> SliceIter<'_, Self> ⓘ
fn pem_slice_iter(pem: &[u8]) -> SliceIter<'_, Self> ⓘ
从一段字节切片中的 PEM 数据里,迭代出本类型的所有 section。
Sourcefn from_pem_file(file_name: impl AsRef<Path>) -> Result<Self, Error>
fn from_pem_file(file_name: impl AsRef<Path>) -> Result<Self, Error>
从指定文件中的 PEM 内容里,解码出本类型的第一个 section。
若未找到相应的项,则返回 Error::NoItemsFound。
Sourcefn pem_file_iter(
file_name: impl AsRef<Path>,
) -> Result<ReadIter<BufReader<File>, Self>, Error>
fn pem_file_iter( file_name: impl AsRef<Path>, ) -> Result<ReadIter<BufReader<File>, Self>, Error>
从指定文件中的 PEM 内容里,迭代出本类型的所有 section。
该方法分两阶段报告错误:
- errors opening the file are reported from this function directly,
- errors reading from the file are reported from the returned iterator,
动态分发兼容性§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.