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§
Sourcefn app_data<T: Any>(&self) -> Result<Option<Rc<T>>, SessionGetAppDataError>
fn app_data<T: Any>(&self) -> Result<Option<Rc<T>>, SessionGetAppDataError>
Returns the application specific data stored alongside this session.
Sourcefn set_app_data<T: 'static + Any>(&self, value: Option<T>)
fn set_app_data<T: 'static + Any>(&self, value: Option<T>)
Sets the application-specific data stored alongside this session.
Sourcefn clear_app_data(&self)
fn clear_app_data(&self)
Clears the application-specific data stored alongside this session.
Sourcefn ack_random_factor(&self) -> (u16, u16)
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.
Sourcefn set_ack_random_factor(&self, integer_part: u16, fractional_part: u16)
fn set_ack_random_factor(&self, integer_part: u16, fractional_part: u16)
Sets the Ack-Random-Factor used by libcoap.
Sourcefn ack_timeout(&self) -> (u16, u16)
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.
Sourcefn set_ack_timeout(&self, integer_part: u16, fractional_part: u16)
fn set_ack_timeout(&self, integer_part: u16, fractional_part: u16)
Sets the value of the Acknowledgement Timeout for this session.
Sourcefn addr_local(&self) -> SocketAddr
fn addr_local(&self) -> SocketAddr
Returns the local address for this session.
Sourcefn addr_remote(&self) -> SocketAddr
fn addr_remote(&self) -> SocketAddr
Returns the remote address for this session.
Sourcefn max_retransmit(&self) -> MaxRetransmit
fn max_retransmit(&self) -> MaxRetransmit
Returns the maximum number of retransmissions for this session.
Sourcefn set_max_retransmit(&mut self, value: MaxRetransmit)
fn set_max_retransmit(&mut self, value: MaxRetransmit)
Sets the maximum number of retransmissions for this session.
Sourcefn proto(&self) -> CoapProtocol
fn proto(&self) -> CoapProtocol
Returns the underlying transport protocol used for this session.
Sourcefn psk_identity(&self) -> Option<Box<[u8]>>
fn psk_identity(&self) -> Option<Box<[u8]>>
Returns the current PSK identity for this session.
Sourcefn state(&self) -> CoapSessionState
fn state(&self) -> CoapSessionState
Returns the current state of this session.
Sourcefn init_token(&self, token: &[u8; 8])
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.
Sourcefn max_pdu_size(&self) -> usize
fn max_pdu_size(&self) -> usize
Returns the maximum size of a PDU for this session.
Sourcefn next_message_id(&self) -> CoapMessageId
fn next_message_id(&self) -> CoapMessageId
Returns the next message ID that should be used for this session.
Sourcefn new_token(&mut self, token: &mut [u8; 8]) -> usize
fn new_token(&mut self, token: &mut [u8; 8]) -> usize
Returns the next token that should be used for requests.
Sourcefn send_ping(&mut self) -> CoapMessageId
fn send_ping(&mut self) -> CoapMessageId
Send a ping message to the remote peer.
Sourcefn send<P: Into<CoapMessage>>(
&self,
pdu: P,
) -> Result<CoapMessageId, MessageConversionError>
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.
Sourcefn send_request(
&self,
req: CoapRequest,
) -> Result<CoapRequestHandle, MessageConversionError>
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.
Sourcefn poll_handle(&self, handle: &CoapRequestHandle) -> IntoIter<CoapResponse>
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.
Sourcefn is_waiting_for_token(&self, token: &CoapToken) -> bool
fn is_waiting_for_token(&self, token: &CoapToken) -> bool
Returns whether this session waits for the provided token.
Sourcefn remove_handle(&self, handle: CoapRequestHandle)
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.
Sourceunsafe fn raw_session_mut(&self) -> *mut coap_session_t
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.
Sourceunsafe fn raw_session(&self) -> *const coap_session_t
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.