pub struct TlsStream<S> { /* private fields */ }
tls
only.Expand description
A reconnectable stream encrypted with TLS.
This can be used as an argument to Consumer::connect_with
and Producer::connect_with
to
connect to a TLS-secured Faktory server.
§Examples
use faktory::{Producer, TlsStream};
let tls = TlsStream::connect(None).unwrap();
let p = Producer::connect_with(tls, None).unwrap();
Implementations§
source§impl TlsStream<TcpStream>
impl TlsStream<TcpStream>
sourcepub fn connect(url: Option<&str>) -> Result<Self, Error>
pub fn connect(url: Option<&str>) -> Result<Self, Error>
Create a new TLS connection over TCP.
If url
is not given, will use the standard Faktory environment variables. Specifically,
FAKTORY_PROVIDER
is read to get the name of the environment variable to get the address
from (defaults to FAKTORY_URL
), and then that environment variable is read to get the
server address. If the latter environment variable is not defined, the connection will be
made to
tcp://localhost:7419
If url
is given, but does not specify a port, it defaults to 7419.
sourcepub fn with_connector(
tls: TlsConnector,
url: Option<&str>
) -> Result<Self, Error>
pub fn with_connector( tls: TlsConnector, url: Option<&str> ) -> Result<Self, Error>
Create a new TLS connection over TCP using a non-default TLS configuration.
See connect
for details about the url
parameter.
Methods from Deref<Target = NativeTlsStream<S>>§
sourcepub fn buffered_read_size(&self) -> Result<usize, Error>
pub fn buffered_read_size(&self) -> Result<usize, Error>
Returns the number of bytes that can be read without resulting in any network calls.
sourcepub fn peer_certificate(&self) -> Result<Option<Certificate>, Error>
pub fn peer_certificate(&self) -> Result<Option<Certificate>, Error>
Returns the peer’s leaf certificate, if available.
Trait Implementations§
source§impl<S: Read + Write> Read for TlsStream<S>
impl<S: Read + Write> Read for TlsStream<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<S: Read + Write> Write for TlsStream<S>
impl<S: Read + Write> Write for TlsStream<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
)