pub struct Encoder<'l, 'o> { /* private fields */ }
pkcs8
only.Expand description
Buffered PEM encoder.
Stateful buffered encoder type which encodes an input PEM document according to RFC 7468’s “Strict” grammar.
Implementations§
§impl<'l, 'o> Encoder<'l, 'o>
impl<'l, 'o> Encoder<'l, 'o>
pub fn new(
type_label: &'l str,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<Encoder<'l, 'o>, Error>
pub fn new( type_label: &'l str, line_ending: LineEnding, out: &'o mut [u8] ) -> Result<Encoder<'l, 'o>, Error>
Create a new PEM Encoder
with the default options which
writes output into the provided buffer.
Uses the default 64-character line wrapping.
pub fn new_wrapped(
type_label: &'l str,
line_width: usize,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<Encoder<'l, 'o>, Error>
pub fn new_wrapped( type_label: &'l str, line_width: usize, line_ending: LineEnding, out: &'o mut [u8] ) -> Result<Encoder<'l, 'o>, Error>
Create a new PEM Encoder
which wraps at the given line width.
Note that per RFC7468 § 2 encoding PEM with any other wrap width besides 64 is technically non-compliant:
Generators MUST wrap the base64-encoded lines so that each line consists of exactly 64 characters except for the final line, which will encode the remainder of the data (within the 64-character line boundary)
This method is provided with the intended purpose of implementing the OpenSSH private key format, which uses a non-standard wrap width of 70.
pub fn type_label(&self) -> &'l str
pub fn type_label(&self) -> &'l str
Get the PEM type label used for this document.
pub fn encode(&mut self, input: &[u8]) -> Result<(), Error>
pub fn encode(&mut self, input: &[u8]) -> Result<(), Error>
Encode the provided input data.
This method can be called as many times as needed with any sized input to write data encoded data into the output buffer, so long as there is sufficient space in the buffer to handle the resulting Base64 encoded data.
pub fn base64_encoder(&mut self) -> &mut Encoder<'o, Base64>
pub fn base64_encoder(&mut self) -> &mut Encoder<'o, Base64>
Borrow the inner Base64Encoder
.