Struct embedded_nal_minimal_coaptcpserver::ConnectionState [−][src]
pub struct ConnectionState<ST: TcpClientStack + TcpExactStack + ?Sized, const CONFIGURED_BUFLEN: usize> { /* fields omitted */ }
Expand description
Internals necessarily carried around per connection.
The type (ST) and CONFIGURED_BUFLEN do not conceptionally need to be tied to the state (even though it makes no sense to apply one state to different stacks or even different sockets at different pollings). It is still carried around to have a buffer length available for stack allocation use, even while ST::RECVBUFLEN is not usable that way.
CONFIGURED_BUFLEN should, on the long run, take its default from ST::SENDBUFLEN and ST::RECVBUFLEN, but that appears to be impossible in Rust at the moment, and implementations may want to use smaller buffers anyway. A reasonable default would be 1152 (the default Maximum-Message-Size, which peers might send without waiting for the CSM).
Implementations
impl<ST: TcpClientStack + TcpExactStack + ?Sized, const CONFIGURED_BUFLEN: usize> ConnectionState<ST, CONFIGURED_BUFLEN>
impl<ST: TcpClientStack + TcpExactStack + ?Sized, const CONFIGURED_BUFLEN: usize> ConnectionState<ST, CONFIGURED_BUFLEN>
pub fn poll_connection(
&mut self,
stack: &mut ST,
handler: &mut impl Handler
) -> Result<!, Error<ST::Error>> where
ST: TcpClientStack + TcpExactStack,
pub fn poll_connection(
&mut self,
stack: &mut ST,
handler: &mut impl Handler
) -> Result<!, Error<ST::Error>> where
ST: TcpClientStack + TcpExactStack,
Attempt to process any pending messages out of the given socket
on a UDP stack
.
Any CoAP requests are dispatched to the handler. A response is built immediately and sent.
Temporary failure to read from any action immediately makes the function return WouldBlock
,
and it should be called again whenever there is indication that the network device is ready
again; same goes for the initial writing of a CSM message that is mandatory in CoAP over TCP.
Any failure to write at response time, as well as protocol errors, are fatal and propagate out as errors. In that case, the socket gets closed, and the function must not be called on this socket again.
There is no successful return; whenever all pending requests have been processed, WouldBlock
indicates that the function has done all it can do right now.
Note that the caveats in the module description apply.
pub fn poll_connection_with_buffer(
&mut self,
stack: &mut ST,
handler: &mut impl Handler,
fullbuf: &mut [u8; CONFIGURED_BUFLEN]
) -> Result<!, Error<ST::Error>> where
ST: TcpClientStack + TcpExactStack,
pub fn poll_connection_with_buffer(
&mut self,
stack: &mut ST,
handler: &mut impl Handler,
fullbuf: &mut [u8; CONFIGURED_BUFLEN]
) -> Result<!, Error<ST::Error>> where
ST: TcpClientStack + TcpExactStack,
Like [poll_connection], but rather than allocating a buffer on the stack (which needs zeroing out), using a provided scratch memory.
In situations where stack space is scarce, this can also take a global scratch space, which is shared with other tasks that don’t run concurrently.