pub struct Client<Cfg: Platform> { /* private fields */ }
Expand description
A blocking CoAP request client
Implementations
sourceimpl Client<StdSecure>
impl Client<StdSecure>
sourcepub fn try_new_secure(port: u16) -> Result<Self>
pub fn try_new_secure(port: u16) -> Result<Self>
Create a new Client secured by DTLS
use kwap::blocking::Client;
use kwap::req::ReqBuilder;
use kwap::ContentFormat;
let mut client = Client::try_new_secure(1234).unwrap();
let req = ReqBuilder::get("127.0.0.1:5683".parse().unwrap(), "hello").accept(ContentFormat::Text)
.build()
.unwrap();
let rep = client.send(req).unwrap();
println!("Hello, {}!", rep.payload_string().unwrap());
sourcepub fn try_new_secure_config(port: u16, config: Config) -> Result<Self>
pub fn try_new_secure_config(port: u16, config: Config) -> Result<Self>
Create a new std client with a specific runtime config
sourceimpl Client<Std>
impl Client<Std>
sourcepub fn new_std() -> Self
pub fn new_std() -> Self
Create a new Client for a platform supporting Rust’s standard library.
use kwap::blocking::Client;
use kwap::req::ReqBuilder;
use kwap::ContentFormat;
let mut client = Client::new_std();
let req = ReqBuilder::get("127.0.0.1:5683".parse().unwrap(), "hello").accept(ContentFormat::Text)
.build()
.unwrap();
let rep = client.send(req).unwrap();
println!("Hello, {}!", rep.payload_string().unwrap());
sourcepub fn new_std_config(config: Config) -> Self
pub fn new_std_config(config: Config) -> Self
Create a new std client with a specific runtime config
sourceimpl<P: Platform> Client<P>
impl<P: Platform> Client<P>
sourcepub fn new(_: ClientConfig<P>) -> Self
pub fn new(_: ClientConfig<P>) -> Self
Create a new request client
sourcepub fn new_config(config: Config, _: ClientConfig<P>) -> Self
pub fn new_config(config: Config, _: ClientConfig<P>) -> Self
Create a new request client with a specific runtime config
sourcepub fn ping(&mut self, host: impl AsRef<str>, port: u16) -> Result<(), Error<P>>
pub fn ping(&mut self, host: impl AsRef<str>, port: u16) -> Result<(), Error<P>>
Ping an endpoint
Note: this will eventually not require Client to be borrowed mutably.
sourcepub fn send(&mut self, req: Req<P>) -> Result<Resp<P>, Error<P>>
pub fn send(&mut self, req: Req<P>) -> Result<Resp<P>, Error<P>>
Send a request
Note: this will eventually not require Client to be borrowed mutably.
sourcepub fn listen_multicast(
clock: P::Clock,
port: u16
) -> Result<Addrd<Req<P>>, Error<P>>
pub fn listen_multicast(
clock: P::Clock,
port: u16
) -> Result<Addrd<Req<P>>, Error<P>>
Listen on a multicast address for a broadcast from a Server
This will time out if nothing has been received after 1 second.
sourcepub fn get(host: SocketAddr, path: impl AsRef<str>) -> ReqBuilder<P>
pub fn get(host: SocketAddr, path: impl AsRef<str>) -> ReqBuilder<P>
Send a GET request
Auto Trait Implementations
impl<Cfg> RefUnwindSafe for Client<Cfg> where
<Cfg as Platform>::Clock: RefUnwindSafe,
<Cfg as Platform>::MessageIdHistoryBySocket: RefUnwindSafe,
<Cfg as Platform>::MessageOptions: RefUnwindSafe,
<Cfg as Platform>::MessagePayload: RefUnwindSafe,
<Cfg as Platform>::MessageTokenHistoryBySocket: RefUnwindSafe,
<Cfg as Platform>::NumberedOptions: RefUnwindSafe,
<Cfg as Platform>::Socket: RefUnwindSafe,
impl<Cfg> Send for Client<Cfg> where
<Cfg as Platform>::Clock: Send,
<Cfg as Platform>::MessageIdHistoryBySocket: Send,
<Cfg as Platform>::MessageOptions: Send,
<Cfg as Platform>::MessagePayload: Send,
<Cfg as Platform>::MessageTokenHistoryBySocket: Send,
<Cfg as Platform>::NumberedOptions: Send,
<Cfg as Platform>::Socket: Send,
impl<Cfg> Sync for Client<Cfg> where
<Cfg as Platform>::Clock: Sync,
<Cfg as Platform>::MessageIdHistoryBySocket: Sync,
<Cfg as Platform>::MessageOptions: Sync,
<Cfg as Platform>::MessagePayload: Sync,
<Cfg as Platform>::MessageTokenHistoryBySocket: Sync,
<Cfg as Platform>::NumberedOptions: Sync,
<Cfg as Platform>::Socket: Sync,
impl<Cfg> Unpin for Client<Cfg> where
<Cfg as Platform>::Clock: Unpin,
<Cfg as Platform>::MessageIdHistoryBySocket: Unpin,
<Cfg as Platform>::MessageOptions: Unpin,
<Cfg as Platform>::MessagePayload: Unpin,
<Cfg as Platform>::MessageTokenHistoryBySocket: Unpin,
<Cfg as Platform>::NumberedOptions: Unpin,
<Cfg as Platform>::Socket: Unpin,
impl<Cfg> UnwindSafe for Client<Cfg> where
<Cfg as Platform>::Clock: UnwindSafe,
<Cfg as Platform>::MessageIdHistoryBySocket: UnwindSafe,
<Cfg as Platform>::MessageOptions: UnwindSafe,
<Cfg as Platform>::MessagePayload: UnwindSafe,
<Cfg as Platform>::MessageTokenHistoryBySocket: UnwindSafe,
<Cfg as Platform>::NumberedOptions: UnwindSafe,
<Cfg as Platform>::Socket: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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