Trait CoapSessionCommon

Source
pub trait CoapSessionCommon<'a>: CoapSessionCommonInternal<'a> {
Show 30 methods // Provided methods fn app_data<T: Any>(&self) -> Result<Option<Rc<T>>, SessionGetAppDataError> { ... } fn set_app_data<T: 'static + Any>(&self, value: Option<T>) { ... } fn clear_app_data(&self) { ... } fn ack_random_factor(&self) -> (u16, u16) { ... } fn set_ack_random_factor(&self, integer_part: u16, fractional_part: u16) { ... } fn ack_timeout(&self) -> (u16, u16) { ... } fn set_ack_timeout(&self, integer_part: u16, fractional_part: u16) { ... } fn addr_local(&self) -> SocketAddr { ... } fn addr_remote(&self) -> SocketAddr { ... } fn if_index(&self) -> IfIndex { ... } fn max_retransmit(&self) -> MaxRetransmit { ... } fn set_max_retransmit(&mut self, value: MaxRetransmit) { ... } fn proto(&self) -> CoapProtocol { ... } fn psk_hint(&self) -> Option<Box<[u8]>> { ... } fn psk_identity(&self) -> Option<Box<[u8]>> { ... } fn psk_key(&self) -> Option<Box<[u8]>> { ... } fn state(&self) -> CoapSessionState { ... } fn init_token(&self, token: &[u8; 8]) { ... } fn max_pdu_size(&self) -> usize { ... } fn set_mtu(&self, mtu: u32) { ... } fn next_message_id(&self) -> CoapMessageId { ... } fn new_token(&mut self, token: &mut [u8; 8]) -> usize { ... } fn send_ping(&mut self) -> CoapMessageId { ... } fn send<P: Into<CoapMessage>>( &self, pdu: P, ) -> Result<CoapMessageId, MessageConversionError> { ... } fn send_request( &self, req: CoapRequest, ) -> Result<CoapRequestHandle, MessageConversionError> { ... } fn poll_handle(&self, handle: &CoapRequestHandle) -> IntoIter<CoapResponse> { ... } fn is_waiting_for_token(&self, token: &CoapToken) -> bool { ... } fn remove_handle(&self, handle: CoapRequestHandle) { ... } unsafe fn raw_session_mut(&self) -> *mut coap_session_t { ... } unsafe fn raw_session(&self) -> *const coap_session_t { ... }
}
Expand description

Trait for functions that are common between client and server sessions.

Provided Methods§

Source

fn app_data<T: Any>(&self) -> Result<Option<Rc<T>>, SessionGetAppDataError>

Returns the application specific data stored alongside this session.

Source

fn set_app_data<T: 'static + Any>(&self, value: Option<T>)

Sets the application-specific data stored alongside this session.

Source

fn clear_app_data(&self)

Clears the application-specific data stored alongside this session.

Source

fn ack_random_factor(&self) -> (u16, u16)

Returns the Ack-Random-Factor used by libcoap.

The returned value is a tuple consisting of an integer and a fractional part, where the fractional part is a value from 0-999 and represents the first three digits after the comma.

Source

fn set_ack_random_factor(&self, integer_part: u16, fractional_part: u16)

Sets the Ack-Random-Factor used by libcoap.

Source

fn ack_timeout(&self) -> (u16, u16)

Returns the current value of the Acknowledgement Timeout for this session (in seconds).

The returned value is a tuple consisting of an integer and a fractional part, where the fractional part is a value from 0-999 and represents the first three digits after the comma.

Source

fn set_ack_timeout(&self, integer_part: u16, fractional_part: u16)

Sets the value of the Acknowledgement Timeout for this session.

Source

fn addr_local(&self) -> SocketAddr

Returns the local address for this session.

Source

fn addr_remote(&self) -> SocketAddr

Returns the remote address for this session.

Source

fn if_index(&self) -> IfIndex

Returns the interface index for this session.

Source

fn max_retransmit(&self) -> MaxRetransmit

Returns the maximum number of retransmissions for this session.

Source

fn set_max_retransmit(&mut self, value: MaxRetransmit)

Sets the maximum number of retransmissions for this session.

Source

fn proto(&self) -> CoapProtocol

Returns the underlying transport protocol used for this session.

Source

fn psk_hint(&self) -> Option<Box<[u8]>>

Returns the current PSK hint for this session.

Source

fn psk_identity(&self) -> Option<Box<[u8]>>

Returns the current PSK identity for this session.

Source

fn psk_key(&self) -> Option<Box<[u8]>>

Returns the current PSK key for this session.

Source

fn state(&self) -> CoapSessionState

Returns the current state of this session.

Source

fn init_token(&self, token: &[u8; 8])

Initializes the initial token value used by libcoap for this session.

This value will be used as the token and incremented for each message sent through this session that does not already have a token set.

Source

fn max_pdu_size(&self) -> usize

Returns the maximum size of a PDU for this session.

Source

fn set_mtu(&self, mtu: u32)

Sets the maximum size of a PDU for this session.

Source

fn next_message_id(&self) -> CoapMessageId

Returns the next message ID that should be used for this session.

Source

fn new_token(&mut self, token: &mut [u8; 8]) -> usize

Returns the next token that should be used for requests.

Source

fn send_ping(&mut self) -> CoapMessageId

Send a ping message to the remote peer.

Source

fn send<P: Into<CoapMessage>>( &self, pdu: P, ) -> Result<CoapMessageId, MessageConversionError>

Send the given message-like object to the peer.

§Errors

Returns a MessageConversionError if the supplied object cannot be converted to a message.

Source

fn send_request( &self, req: CoapRequest, ) -> Result<CoapRequestHandle, MessageConversionError>

Sends the given CoapRequest, returning a CoapRequestHandle that can be used to poll the request for completion.

§Errors

Returns a MessageConversionError if the given Request could not be converted into a raw message.

Source

fn poll_handle(&self, handle: &CoapRequestHandle) -> IntoIter<CoapResponse>

Polls whether the request for the given handle already has pending responses.

Returns an iterator over all responses associated with the request.

§Panics

Panics if the provided handle does not refer to a valid token, i.e., because it belongs to a different session.

Source

fn is_waiting_for_token(&self, token: &CoapToken) -> bool

Returns whether this session waits for the provided token.

Source

fn remove_handle(&self, handle: CoapRequestHandle)

Stops listening for responses to this request handle.

Any future responses to the request associated with this handle will be responded to with an RST message.

Source

unsafe fn raw_session_mut(&self) -> *mut coap_session_t

Returns a mutable reference to the underlying raw session.

§Safety

Do not do anything that would interfere with the functionality of this wrapper. Most importantly, do not free the session yourself.

Source

unsafe fn raw_session(&self) -> *const coap_session_t

Returns a reference to the underlying raw session.

§Safety

Do not do anything that would interfere with the functionality of this wrapper. Most importantly, do not free the session yourself.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T: CoapSessionCommonInternal<'a>> CoapSessionCommon<'a> for T