Trait w5500_hl::Common[][src]

pub trait Common<E>: Registers<Error = E> {
    fn local_addr(&mut self, socket: Socket) -> Result<SocketAddrV4, E> { ... }
fn close(&mut self, socket: Socket) -> Result<(), E> { ... }
fn is_state_closed(&mut self, socket: Socket) -> Result<bool, E> { ... }
fn is_state_tcp(&mut self, socket: Socket) -> Result<bool, E> { ... }
fn is_state_udp(&mut self, socket: Socket) -> Result<bool, E> { ... } }

Methods common to all W5500 socket types.

Provided methods

fn local_addr(&mut self, socket: Socket) -> Result<SocketAddrV4, E>[src]

Returns the socket address.

Example

use w5500_hl::ll::{Registers, Socket::Socket0};
use w5500_hl::{Common, Udp};

w5500.udp_bind(Socket0, 8080)?;
let local_addr = w5500.local_addr(Socket0)?;

fn close(&mut self, socket: Socket) -> Result<(), E>[src]

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, Socket::Socket0};
use w5500_hl::Common;

w5500.close(Socket0)?;

fn is_state_closed(&mut self, socket: Socket) -> Result<bool, E>[src]

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, Socket::Socket0};
use w5500_hl::{Common, Udp};

w5500.close(Socket0)?;
assert!(w5500.is_state_closed(Socket0)?);
w5500.udp_bind(Socket0, 8080)?;
assert!(!w5500.is_state_closed(Socket0)?);

fn is_state_tcp(&mut self, socket: Socket) -> Result<bool, E>[src]

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, Socket::Socket0};
use w5500_hl::{Common, Udp};

w5500.close(Socket0)?;
assert!(w5500.is_state_tcp(Socket0)?);
w5500.udp_bind(Socket0, 8080)?;
assert!(!w5500.is_state_tcp(Socket0)?);

fn is_state_udp(&mut self, socket: Socket) -> Result<bool, E>[src]

Returns true if the socket state is Udp.

Example

use w5500_hl::ll::{Registers, Socket::Socket0};
use w5500_hl::{Common, Udp};

w5500.close(Socket0)?;
assert!(!w5500.is_state_udp(Socket0)?);
w5500.udp_bind(Socket0, 8080)?;
assert!(w5500.is_state_udp(Socket0)?);
Loading content...

Implementors

impl<T, E> Common<E> for T where
    T: Registers<Error = E>, 
[src]

Implement the common socket trait for any structure that implements w5500_ll::Registers.

Loading content...