Trait w5500_hl::Common [−][src]
pub trait Common: Registers {
fn local_addr(&mut self, sn: Sn) -> Result<SocketAddrV4, Self::Error> { ... }
fn close(&mut self, sn: Sn) -> Result<(), Self::Error> { ... }
fn is_state_closed(&mut self, sn: Sn) -> Result<bool, Self::Error> { ... }
fn is_state_tcp(&mut self, sn: Sn) -> Result<bool, Self::Error> { ... }
fn is_state_udp(&mut self, sn: Sn) -> Result<bool, Self::Error> { ... }
}
Expand description
Methods common to all W5500 socket types.
Provided methods
fn local_addr(&mut self, sn: Sn) -> Result<SocketAddrV4, Self::Error>
fn local_addr(&mut self, sn: Sn) -> Result<SocketAddrV4, Self::Error>
Returns the socket address.
Example
use w5500_hl::ll::{Registers, Sn::Sn0};
use w5500_hl::{Common, Udp};
w5500.udp_bind(Sn0, 8080)?;
let local_addr = w5500.local_addr(Sn0)?;
Close a socket.
This will not poll for completion, the socket may not be closed after this method has returned.
Example
use w5500_hl::ll::{Registers, Sn::Sn0};
use w5500_hl::Common;
w5500.close(Sn0)?;
Returns true
if the socket state is Closed.
Note: This does not include states that indicate the socket is about to close, such as Closing.
Example
use w5500_hl::ll::{Registers, Sn::Sn0};
use w5500_hl::{Common, Udp};
w5500.close(Sn0)?;
assert!(w5500.is_state_closed(Sn0)?);
w5500.udp_bind(Sn0, 8080)?;
assert!(!w5500.is_state_closed(Sn0)?);
Returns true
if the socket state is any valid TCP state as described
in RFC 793.
Valid TCP states include:
Note: This does not include the W5500 Init state.
Example
use w5500_hl::ll::{Registers, Sn::Sn0};
use w5500_hl::{Common, Udp};
w5500.close(Sn0)?;
assert!(w5500.is_state_tcp(Sn0)?);
w5500.udp_bind(Sn0, 8080)?;
assert!(!w5500.is_state_tcp(Sn0)?);
Implementors
Implement the common socket trait for any structure that implements w5500_ll::Registers
.