Struct age::armor::ArmoredWriter
source · pub struct ArmoredWriter<W>(/* private fields */);
Expand description
Writer that optionally applies the age ASCII armor format.
§Examples
use std::io::Write;
let recipient = load_recipient()?;
let plaintext = b"Hello world!";
let encrypted = {
let encryptor = age::Encryptor::with_recipients(vec![Box::new(recipient)])
.expect("we provided a recipient");
let mut encrypted = vec![];
let mut writer = encryptor.wrap_output(
age::armor::ArmoredWriter::wrap_output(
&mut encrypted,
age::armor::Format::AsciiArmor,
)?
)?;
writer.write_all(plaintext)?;
writer.finish()
.and_then(|armor| armor.finish())?;
encrypted
};
Implementations§
source§impl<W: Write> ArmoredWriter<W>
impl<W: Write> ArmoredWriter<W>
sourcepub fn wrap_output(output: W, format: Format) -> Result<Self>
Available on crate feature armor
only.
pub fn wrap_output(output: W, format: Format) -> Result<Self>
armor
only.Wraps the given output in an ArmoredWriter
that will apply the given Format
.
sourcepub fn finish(self) -> Result<W>
Available on crate feature armor
only.
pub fn finish(self) -> Result<W>
armor
only.Writes the end marker of the age file, if armoring was enabled.
You MUST call finish
when you are done writing, in order to finish the
armoring process. Failing to call finish
will result in a truncated file that
that will fail to decrypt.
source§impl<W: AsyncWrite> ArmoredWriter<W>
impl<W: AsyncWrite> ArmoredWriter<W>
sourcepub fn wrap_async_output(output: W, format: Format) -> Self
Available on crate features armor
and async
only.
pub fn wrap_async_output(output: W, format: Format) -> Self
armor
and async
only.Wraps the given output in an ArmoredWriter
that will apply the given Format
.
Trait Implementations§
source§impl<W: AsyncWrite> AsyncWrite for ArmoredWriter<W>
Available on crate features armor
and async
only.
impl<W: AsyncWrite> AsyncWrite for ArmoredWriter<W>
Available on crate features
armor
and async
only.source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>
Attempt to write bytes from
buf
into the object. Read moresource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
source§impl<W: Write> Write for ArmoredWriter<W>
Available on crate feature armor
only.
impl<W: Write> Write for ArmoredWriter<W>
Available on crate feature
armor
only.source§fn 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
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn 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
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
impl<'pin, W> Unpin for ArmoredWriter<W>where
__ArmoredWriter<'pin, W>: Unpin,
Available on crate feature
armor
only.Auto Trait Implementations§
impl<W> RefUnwindSafe for ArmoredWriter<W>where
W: RefUnwindSafe,
impl<W> Send for ArmoredWriter<W>where
W: Send,
impl<W> Sync for ArmoredWriter<W>where
W: Sync,
impl<W> UnwindSafe for ArmoredWriter<W>where
W: UnwindSafe,
Blanket Implementations§
§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
§fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
Creates a future which will entirely flush this
AsyncWrite
. Read more§fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
Creates a future which will entirely close this
AsyncWrite
.§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
Creates a future which will write bytes from
buf
into the object. Read more§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self>where
Self: Unpin,
Creates a future which will write bytes from
bufs
into the object using vectored
IO operations. Read moresource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more