pub struct TlsReader<'buf, 'ptr> { /* private fields */ }
Expand description
Reader for a TLS application data record.
This implements the w5500-hl
IO traits, Read
and Seek
.
Created by Client::reader
.
§Example
use w5500_tls::{
Client, Event, TlsReader,
{
hl::{io::Read, 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 there is application data
// for demonstration purposes only, please do not actually do this
while tls_client.process(&mut w5500, &mut rng, monotonic_secs()) != Ok(Event::ApplicationData) {
}
let mut reader: TlsReader = tls_client.reader()?;
let mut buf: [u8; 5] = [0; 5];
reader.read_exact(&mut buf)?;
reader.done()?;
Trait Implementations§
source§impl<'buf, 'ptr> PartialEq for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> PartialEq for TlsReader<'buf, 'ptr>
source§impl<'buf, 'ptr> Read<Infallible> for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> Read<Infallible> for TlsReader<'buf, 'ptr>
source§impl<'buf, 'ptr> Seek for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> Seek for TlsReader<'buf, 'ptr>
source§fn seek<Infallible>(&mut self, pos: SeekFrom) -> Result<(), HlError<Infallible>>
fn seek<Infallible>(&mut self, pos: SeekFrom) -> Result<(), HlError<Infallible>>
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.
impl<'buf, 'ptr> Eq for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> StructuralPartialEq for TlsReader<'buf, 'ptr>
Auto Trait Implementations§
impl<'buf, 'ptr> Freeze for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> RefUnwindSafe for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> Send for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> Sync for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> Unpin for TlsReader<'buf, 'ptr>
impl<'buf, 'ptr> !UnwindSafe for TlsReader<'buf, 'ptr>
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