Struct w5500_tls::TlsReader

source ·
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> Debug for TlsReader<'buf, 'ptr>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'buf, 'ptr> Format for TlsReader<'buf, 'ptr>

source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
source§

impl<'buf, 'ptr> PartialEq for TlsReader<'buf, 'ptr>

source§

fn eq(&self, other: &TlsReader<'buf, 'ptr>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'buf, 'ptr> Read<Infallible> for TlsReader<'buf, 'ptr>

source§

fn read(&mut self, buf: &mut [u8]) -> Result<u16, Infallible>

Read data from the UDP socket, and return the number of bytes read.
source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), HlError<Infallible>>

Read the exact number of bytes required to fill buf. Read more
source§

fn done(self) -> Result<(), Infallible>

Mark the data as read, removing the data from the queue. Read more
source§

impl<'buf, 'ptr> Seek for TlsReader<'buf, 'ptr>

source§

fn seek<Infallible>(&mut self, pos: SeekFrom) -> Result<(), HlError<Infallible>>

Seek to an offset, in bytes, within the socket buffer. Read more
source§

fn rewind(&mut self)

Rewind to the beginning of the stream. Read more
source§

fn stream_len(&self) -> u16

Return the length of the stream, in bytes. Read more
source§

fn stream_position(&self) -> u16

Returns the current seek position from the start of the stream.
source§

fn remain(&self) -> u16

Remaining bytes in the socket buffer from the current seek position.
source§

impl<'buf, 'ptr> Eq for TlsReader<'buf, 'ptr>

source§

impl<'buf, 'ptr> StructuralEq for TlsReader<'buf, 'ptr>

source§

impl<'buf, 'ptr> StructuralPartialEq for TlsReader<'buf, 'ptr>

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.