Struct libcoap_rs::session::client::CoapClientSession
source · pub struct CoapClientSession<'a> { /* private fields */ }
Expand description
Representation of a client-side CoAP session.
Implementations
sourceimpl CoapClientSession<'_>
impl CoapClientSession<'_>
sourcepub fn connect_dtls<'a, 'b, P: 'static + CoapClientCryptoProvider>(
ctx: &'b mut CoapContext<'a>,
addr: SocketAddr,
crypto_provider: P
) -> Result<CoapClientSession<'a>, SessionCreationError>
pub fn connect_dtls<'a, 'b, P: 'static + CoapClientCryptoProvider>(
ctx: &'b mut CoapContext<'a>,
addr: SocketAddr,
crypto_provider: P
) -> Result<CoapClientSession<'a>, SessionCreationError>
Create a new DTLS encrypted session with the given peer.
To supply cryptographic information (like PSK hints or key data), you have to provide a struct implementing CoapClientCryptoProvider.
Errors
Will return a SessionCreationError if libcoap was unable to create a session (most likely because it was not possible to bind to a port).
sourcepub fn connect_udp<'a>(
ctx: &mut CoapContext<'a>,
addr: SocketAddr
) -> Result<CoapClientSession<'a>, SessionCreationError>
pub fn connect_udp<'a>(
ctx: &mut CoapContext<'a>,
addr: SocketAddr
) -> Result<CoapClientSession<'a>, SessionCreationError>
Create a new unencrypted session with the given peer over UDP.
Errors
Will return a SessionCreationError if libcoap was unable to create a session (most likely because it was not possible to bind to a port).
sourcepub fn set_crypto_provider(
&mut self,
crypto_provider: Option<Box<dyn CoapClientCryptoProvider>>
)
pub fn set_crypto_provider(
&mut self,
crypto_provider: Option<Box<dyn CoapClientCryptoProvider>>
)
Sets the provider for cryptographic information for this session.
Trait Implementations
sourceimpl<'a> Clone for CoapClientSession<'a>
impl<'a> Clone for CoapClientSession<'a>
sourcefn clone(&self) -> CoapClientSession<'a>
fn clone(&self) -> CoapClientSession<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl<'a> Debug for CoapClientSession<'a>
impl<'a> Debug for CoapClientSession<'a>
sourceimpl<'a> From<CoapClientSession<'a>> for CoapSession<'a>
impl<'a> From<CoapClientSession<'a>> for CoapSession<'a>
sourcefn from(session: CoapClientSession<'a>) -> Self
fn from(session: CoapClientSession<'a>) -> Self
Converts to this type from the input type.
sourceimpl<'a, T: CoapSessionCommon<'a>> PartialEq<T> for CoapClientSession<'_>
impl<'a, T: CoapSessionCommon<'a>> PartialEq<T> for CoapClientSession<'_>
impl Eq for CoapClientSession<'_>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for CoapClientSession<'a>
impl<'a> !Send for CoapClientSession<'a>
impl<'a> !Sync for CoapClientSession<'a>
impl<'a> Unpin for CoapClientSession<'a>
impl<'a> !UnwindSafe for CoapClientSession<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, T> CoapSessionCommon<'a> for Twhere
T: CoapSessionCommonInternal<'a>,
impl<'a, T> CoapSessionCommon<'a> for Twhere
T: CoapSessionCommonInternal<'a>,
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. Read more
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). Read more
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_hint(&self) -> Option<Box<CoapCryptoPskIdentity>>
fn psk_hint(&self) -> Option<Box<CoapCryptoPskIdentity>>
Returns the current PSK hint for this session.
sourcefn psk_identity(&self) -> Option<Box<CoapCryptoPskIdentity>>
fn psk_identity(&self) -> Option<Box<CoapCryptoPskIdentity>>
Returns the current PSK identity for this session.
sourcefn psk_key(&self) -> Option<Box<CoapCryptoPskData>>
fn psk_key(&self) -> Option<Box<CoapCryptoPskData>>
Returns the current PSK key 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 token value used by libcoap. Read more
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. Read more
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. Read more
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. Read more
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. Read more
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. Read more
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. Read more