Struct w5500_hl::UdpWriter

source ·
pub struct UdpWriter<'w, W5500> { /* private fields */ }
Expand description

Streaming writer for a UDP socket buffer.

This implements the Seek traits.

Created with Udp::udp_writer.

Example

use w5500_hl::{
    io::Write,
    ll::{Registers, Sn::Sn0},
    net::{Ipv4Addr, SocketAddrV4},
    Udp, UdpWriter,
};

const DEST: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(192, 0, 2, 1), 8081);

w5500.udp_bind(Sn0, 8080)?;

let mut udp_writer: UdpWriter<_> = w5500.udp_writer(Sn0)?;

let data_header: [u8; 10] = [0; 10];
let n_written: u16 = udp_writer.write(&data_header)?;
assert_eq!(usize::from(n_written), data_header.len());

let data: [u8; 123] = [0; 123];
let n_written: u16 = udp_writer.write(&data)?;
assert_eq!(usize::from(n_written), data.len());

udp_writer.udp_send_to(&DEST)?;

Implementations§

source§

impl<'w, W5500: Registers> UdpWriter<'w, W5500>

source

pub fn udp_send_to(self, addr: &SocketAddrV4) -> Result<(), W5500::Error>

Send all data previously written with UdpWriter::write and UdpWriter::write_all to the given address.

Panics
  • (debug) The socket must be opened as a UDP socket.

Trait Implementations§

source§

impl<'w, W5500: Debug> Debug for UdpWriter<'w, W5500>

source§

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

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

impl<'w, W5500> Format for UdpWriter<'w, W5500>where W5500: Format,

source§

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

Writes the defmt representation of self to fmt.
source§

impl<'w, W5500: PartialEq> PartialEq for UdpWriter<'w, W5500>

source§

fn eq(&self, other: &UdpWriter<'w, W5500>) -> 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<'w, W5500> Seek for UdpWriter<'w, W5500>

source§

fn seek<E>(&mut self, pos: SeekFrom) -> Result<(), Error<E>>

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<'w, W5500: Registers> Write<<W5500 as Registers>::Error> for UdpWriter<'w, W5500>

source§

fn write(&mut self, buf: &[u8]) -> Result<u16, W5500::Error>

Write data to the socket buffer, and return the number of bytes written.
source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error<W5500::Error>>

Writes all the data, returning Error::OutOfMemory if the size of buf exceeds the free memory available in the socket buffer. Read more
source§

fn send(self) -> Result<(), W5500::Error>

Send all data previously written with write and write_all. Read more
source§

impl<'w, W5500: Eq> Eq for UdpWriter<'w, W5500>

source§

impl<'w, W5500> StructuralEq for UdpWriter<'w, W5500>

source§

impl<'w, W5500> StructuralPartialEq for UdpWriter<'w, W5500>

Auto Trait Implementations§

§

impl<'w, W5500> RefUnwindSafe for UdpWriter<'w, W5500>where W5500: RefUnwindSafe,

§

impl<'w, W5500> Send for UdpWriter<'w, W5500>where W5500: Send,

§

impl<'w, W5500> Sync for UdpWriter<'w, W5500>where W5500: Sync,

§

impl<'w, W5500> Unpin for UdpWriter<'w, W5500>

§

impl<'w, W5500> !UnwindSafe for UdpWriter<'w, W5500>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.