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: PartialEq> PartialEq for TcpWriter<'w, W5500>
impl<'w, W5500: PartialEq> PartialEq for TcpWriter<'w, W5500>
source§impl<'w, W5500> Seek for TcpWriter<'w, W5500>
impl<'w, W5500> Seek for TcpWriter<'w, W5500>
source§fn seek<E>(&mut self, pos: SeekFrom) -> Result<(), Error<E>>
fn seek<E>(&mut self, pos: SeekFrom) -> Result<(), Error<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, W5500: Registers> Write<<W5500 as Registers>::Error> for TcpWriter<'w, W5500>
impl<'w, W5500: Registers> Write<<W5500 as Registers>::Error> for TcpWriter<'w, 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.
impl<'w, W5500: Eq> Eq for TcpWriter<'w, W5500>
impl<'w, W5500> StructuralEq for TcpWriter<'w, W5500>
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> 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