pub struct TlsWriter<'w, 'ks, W5500: Registers> { /* private fields */ }
Expand description
Writer for a TLS application data record.
This implements the w5500-hl
IO traits, Write
and Seek
.
Created by Client::writer
.
This writes plaintext to the socket buffers. When Write::send
is called
the data in the socket buffers is encrypted, and has the appropriate headers
and footers added.
§Example
use w5500_tls::{
Client, Event, TlsWriter,
{
hl::{io::Write, Hostname},
ll::{
net::{Ipv4Addr, SocketAddrV4},
Sn,
},
},
};
static mut RX: [u8; 2048] = [0; 2048];
const DST: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 4), 8883);
const HOSTNAME: Hostname = Hostname::new_unwrapped("server.local");
const SRC_PORT: u16 = 1234;
const TLS_SN: Sn = Sn::Sn4;
let mut tls_client: Client<2048> = Client::new(
TLS_SN,
SRC_PORT,
HOSTNAME,
DST,
b"mykeyidentity",
&MY_KEY,
unsafe { &mut RX },
);
// wait until the handshake has completed
// for demonstration purposes only, please do not actually do this
while tls_client.process(&mut w5500, &mut rng, monotonic_secs()) != Ok(Event::HandshakeFinished)
{
}
let mut writer: TlsWriter<_> = tls_client.writer(&mut w5500).unwrap();
writer.write_all(&[0xAA; 5])?;
writer.send()?;
Trait Implementations§
source§impl<'w, 'ks, W5500: Registers> Seek for TlsWriter<'w, 'ks, W5500>
impl<'w, 'ks, W5500: Registers> Seek for TlsWriter<'w, 'ks, W5500>
source§fn seek<E>(&mut self, pos: SeekFrom) -> Result<(), HlError<E>>
fn seek<E>(&mut self, pos: SeekFrom) -> Result<(), HlError<E>>
Seek to an offset, in bytes, within the socket buffer. Read more
source§fn stream_len(&self) -> u16
fn stream_len(&self) -> u16
Return the length of the stream, in bytes. Read more
source§fn stream_position(&self) -> u16
fn stream_position(&self) -> u16
Returns the current seek position from the start of the stream.
source§impl<'w, 'ks, W5500: Registers> Write<<W5500 as Registers>::Error> for TlsWriter<'w, 'ks, W5500>
impl<'w, 'ks, W5500: Registers> Write<<W5500 as Registers>::Error> for TlsWriter<'w, 'ks, W5500>
source§fn write(&mut self, buf: &[u8]) -> Result<u16, W5500::Error>
fn write(&mut self, buf: &[u8]) -> Result<u16, W5500::Error>
Write data to the socket buffer, and return the number of bytes written.
Auto Trait Implementations§
impl<'w, 'ks, W5500> Freeze for TlsWriter<'w, 'ks, W5500>
impl<'w, 'ks, W5500> RefUnwindSafe for TlsWriter<'w, 'ks, W5500>where
W5500: RefUnwindSafe,
impl<'w, 'ks, W5500> Send for TlsWriter<'w, 'ks, W5500>where
W5500: Send,
impl<'w, 'ks, W5500> Sync for TlsWriter<'w, 'ks, W5500>where
W5500: Sync,
impl<'w, 'ks, W5500> Unpin for TlsWriter<'w, 'ks, W5500>
impl<'w, 'ks, W5500> !UnwindSafe for TlsWriter<'w, 'ks, W5500>
Blanket Implementations§
source§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