Struct box_stream::BoxDuplex
[−]
[src]
pub struct BoxDuplex<S> { /* fields omitted */ }
Wraps a duplex stream, encrypting all writes and decrypting all reads.
Methods
impl<S> BoxDuplex<S>
[src]
pub fn new(
inner: S,
encryption_key: Key,
decryption_key: Key,
encryption_nonce: Nonce,
decryption_nonce: Nonce
) -> BoxDuplex<S>
[src]
inner: S,
encryption_key: Key,
decryption_key: Key,
encryption_nonce: Nonce,
decryption_nonce: Nonce
) -> BoxDuplex<S>
Create a new duplex stream, wrapping inner
and the supplied keys and
nonces for encryption and decryption.
pub fn get_ref(&self) -> &S
[src]
Gets a reference to the underlying stream.
pub fn get_mut(&mut self) -> &mut S
[src]
Gets a mutable reference to the underlying stream.
It is inadvisable to directly write to or read from the underlying stream.
pub fn into_inner(self) -> S
[src]
Unwraps this BoxDuplex
, returning the underlying stream.
Trait Implementations
impl<R: AsyncRead> AsyncRead for BoxDuplex<R>
[src]
fn poll_read(&mut self, cx: &mut Context, buf: &mut [u8]) -> Poll<usize, Error>
[src]
Read bytes from the wrapped reader and decrypt them. End of stream is signalled by
returning Ok(0)
even though this function was passed a buffer of nonzero length.
Errors
In addition to propagating all errors from the wrapped reader, a
BoxReader
produces the following error kinds:
ErrorKind::InvalidData
: If data could not be decrypted, or if a header declares an invalid length. Possible error values areINVALID_LENGTH
,UNAUTHENTICATED_HEADER
,UNAUTHENTICATED_PACKET
.ErrorKind::UnexpectedEof
: If a call to the inner reader returnedOk(0)
although it was given a buffer of nonzero length. This is an error since end of file must be signalled via a special header in a box stream. The error value for this isUNAUTHENTICATED_EOF
.
unsafe fn initializer(&self) -> Initializer
[src]
Determines if this AsyncRead
er can work with buffers of uninitialized memory. Read more
fn poll_vectored_read(
&mut self,
cx: &mut Context,
vec: &mut [&mut IoVec]
) -> Result<Async<usize>, Error>
[src]
&mut self,
cx: &mut Context,
vec: &mut [&mut IoVec]
) -> Result<Async<usize>, Error>
Attempt to read from the AsyncRead
into vec
using vectored IO operations. Read more
impl<W: AsyncWrite> AsyncWrite for BoxDuplex<W>
[src]
fn poll_write(&mut self, cx: &mut Context, buf: &[u8]) -> Poll<usize, Error>
[src]
Attempt to write bytes from buf
into the object. Read more
fn poll_flush(&mut self, cx: &mut Context) -> Poll<(), Error>
[src]
Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
fn poll_close(&mut self, cx: &mut Context) -> Poll<(), Error>
[src]
Attempt to close the object. Read more
fn poll_vectored_write(
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
[src]
&mut self,
cx: &mut Context,
vec: &[&IoVec]
) -> Result<Async<usize>, Error>
Attempt to write bytes from vec
into the object using vectored IO operations. Read more