pub struct RustTlsDuplexStream<C, S>{ /* private fields */ }Implementations§
Source§impl<C, S> RustTlsDuplexStream<C, S>
impl<C, S> RustTlsDuplexStream<C, S>
Sourcepub fn new_unpooled<R, W>(con: C, read: R, write: W) -> Result<Self>
pub fn new_unpooled<R, W>(con: C, read: R, write: W) -> Result<Self>
Creates a new ‘unpooled’ Tls stream wrapper. This is a good choice for an application such as a client that does not create connections and doesn’t have a thread pool.
This fn will spawn 2 new threads using thread::Builder::new().spawn(...).
The threads will terminate when the returned stream is dropped and the read/write errors out.
§Resource Leaks
Be aware that a Read which “blocks” forever will cause the thread that’s reading to stay alive forever.
Either set a reasonable connection read timeout so that your Read will eventually return
or call your connections shutdown fn like TcpStream::shutdown if such a method exists
to ensure that all threads are stopped and no resources are leaked.
§Errors
if thread::Builder::new().spawn fails to spawn 2 threads.
Sourcepub fn new<R, W, T>(con: C, read: R, write: W, spawner: T) -> Result<Self>
pub fn new<R, W, T>(con: C, read: R, write: W, spawner: T) -> Result<Self>
Creates a new Tls stream wrapper.
This fn will spawn 2 new threads using the provided thread spawner function. The thread spawner function is called exactly twice. If the first call yields an error then it’s not called again. The functions (“threads”) will end when the returned stream wrapper is dropped.
§Resource Leaks
Be aware that a Read which “blocks” forever will cause the thread that’s reading to stay alive forever.
Either set a reasonable connection read timeout so that your Read will eventually return
or call your connections shutdown fn like TcpStream::shutdown if such a method exists
to ensure that all threads are stopped and no resources are leaked.
§Errors
propagated from the spawner fn.
Sourcepub fn write(&self, buffer: &[u8]) -> Result<usize>
pub fn write(&self, buffer: &[u8]) -> Result<usize>
see Write::write
§Errors
propagated from Write::write once subsequent writes/flushes turn into BrokenPipe
Sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
see Write::flush
§Errors
propagated from Write::flush once subsequent writes/flushes turn into BrokenPipe
Sourcepub fn set_read_timeout(&self, timeout: Option<Duration>) -> Result<()>
pub fn set_read_timeout(&self, timeout: Option<Duration>) -> Result<()>
sets the timeout for the writing operation.
This has no effect on the underlying connection and purely deals with internal writing semantics.
Calls to fns that writs data will return TimedOut if no plain text data could be written.
Cause of this is likely to be that the underlying connection does not read data fast enough.
This is never caused by writing too much data.
§Errors
In case of poisoned mutex
Sourcepub fn read_timeout(&self) -> Result<Option<Duration>>
pub fn read_timeout(&self) -> Result<Option<Duration>>
Sourcepub fn set_read_non_block(&self, on: bool) -> Result<()>
pub fn set_read_non_block(&self, on: bool) -> Result<()>
sets non-blocking mode for read.
This has no effect on the underlying connection and purely deals with internal reading semantics.
Calls to fns that read data will return WouldBlock immediately if no plain text data is available to be read.
§Errors
In case of poisoned mutex
Sourcepub fn set_write_timeout(&self, timeout: Option<Duration>) -> Result<()>
pub fn set_write_timeout(&self, timeout: Option<Duration>) -> Result<()>
sets the timeout for the writing operation.
This has no effect on the underlying connection and purely deals with internal writing semantics.
Calls to fns that writs data will return TimedOut if no plain text data could be written.
Cause of this is likely to be that the underlying connection does not send data fast enough.
This is never caused by reading too much data.
§Errors
In case of poisoned mutex
Sourcepub fn write_timeout(&self) -> Result<Option<Duration>>
pub fn write_timeout(&self) -> Result<Option<Duration>>
Sourcepub fn read_to_string(&self, buf: &mut String) -> Result<usize>
pub fn read_to_string(&self, buf: &mut String) -> Result<usize>
Trait Implementations§
Source§impl<C, S: Debug> Debug for RustTlsDuplexStream<C, S>
impl<C, S: Debug> Debug for RustTlsDuplexStream<C, S>
Source§impl<C, S> Read for &RustTlsDuplexStream<C, S>
impl<C, S> Read for &RustTlsDuplexStream<C, S>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read moreSource§impl<C, S> Read for RustTlsDuplexStream<C, S>
impl<C, S> Read for RustTlsDuplexStream<C, S>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read moreSource§impl<C, S> Write for &RustTlsDuplexStream<C, S>
impl<C, S> Write for &RustTlsDuplexStream<C, S>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Source§impl<C, S> Write for RustTlsDuplexStream<C, S>
impl<C, S> Write for RustTlsDuplexStream<C, S>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)