Struct w5500_hl::TcpWriter

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

Streaming writer for a TCP socket buffer.

This implements the Seek traits.

Created with Tcp::tcp_writer.

Example

use w5500_hl::{
    io::Write,
    ll::{Registers, Sn, SocketInterrupt},
    net::{Ipv4Addr, SocketAddrV4},
    Tcp, TcpWriter,
};

const MQTT_SOCKET: Sn = Sn::Sn0;
const MQTT_SOURCE_PORT: u16 = 33650;
const MQTT_SERVER: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(192, 168, 2, 10), 1883);

w5500.tcp_connect(MQTT_SOCKET, MQTT_SOURCE_PORT, &MQTT_SERVER)?;

// ... wait for a CON interrupt

const CONNECT: [u8; 14] = [
    0x10, 0x0C, 0x00, 0x04, b'M', b'Q', b'T', b'T', 0x04, 0x02, 0x0E, 0x10, 0x00, 0x00,
];
let mut writer: TcpWriter<_> = w5500.tcp_writer(MQTT_SOCKET)?;
writer.write_all(&CONNECT)?;
writer.send()?;

Trait Implementations§

source§

impl<'w, W5500: Debug> Debug for TcpWriter<'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 TcpWriter<'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 TcpWriter<'w, W5500>

source§

fn eq(&self, other: &TcpWriter<'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 TcpWriter<'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 TcpWriter<'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 TcpWriter<'w, W5500>

source§

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

source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'w, W5500> !UnwindSafe for TcpWriter<'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.