Struct pem_rfc7468::Encoder
source · [−]pub struct Encoder<'l, 'o> { /* private fields */ }
Expand description
Buffered PEM encoder.
Stateful buffered encoder type which encodes an input PEM document according to RFC 7468’s “Strict” grammar.
Implementations
sourceimpl<'l, 'o> Encoder<'l, 'o>
impl<'l, 'o> Encoder<'l, 'o>
sourcepub fn new(
type_label: &'l str,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<Self>
pub fn new(
type_label: &'l str,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<Self>
Create a new PEM Encoder
with the default options which
writes output into the provided buffer.
Uses the default 64-character line wrapping.
sourcepub fn new_wrapped(
type_label: &'l str,
line_width: usize,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<Self>
pub fn new_wrapped(
type_label: &'l str,
line_width: usize,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<Self>
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.
sourcepub fn type_label(&self) -> &'l str
pub fn type_label(&self) -> &'l str
Get the PEM type label used for this document.
sourcepub fn encode(&mut self, input: &[u8]) -> Result<()>
pub fn encode(&mut self, input: &[u8]) -> Result<()>
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.
sourcepub fn base64_encoder(&mut self) -> &mut Base64Encoder<'o>
pub fn base64_encoder(&mut self) -> &mut Base64Encoder<'o>
Borrow the inner Base64Encoder
.
Trait Implementations
sourceimpl<'l, 'o> Write for Encoder<'l, 'o>
Available on crate feature std
only.
impl<'l, 'o> Write for Encoder<'l, 'o>
std
only.sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations
impl<'l, 'o> RefUnwindSafe for Encoder<'l, 'o>
impl<'l, 'o> Send for Encoder<'l, 'o>
impl<'l, 'o> Sync for Encoder<'l, 'o>
impl<'l, 'o> Unpin for Encoder<'l, 'o>
impl<'l, 'o> !UnwindSafe for Encoder<'l, 'o>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more