pub struct Client { /* private fields */ }Expand description
The cometd client.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
base_url: &str,
access_token: &str,
timeout: Duration,
) -> Result<Client, Error>
pub fn new( base_url: &str, access_token: &str, timeout: Duration, ) -> Result<Client, Error>
Creates a new cometd client. It is expected to provide the url of the cometd server, the access token to allow the communication and the timeout for long-polling requests.
§Errors
Will return an error if the http client cannot be initalized.
Sourcepub fn set_retries(self, retries: i8) -> Self
pub fn set_retries(self, retries: i8) -> Self
Sets the number of retries the client will attempt in case of an error or a retry advice is returned by the cometd server.
Sourcepub fn connect(&mut self) -> Result<Vec<Response>, Error>
pub fn connect(&mut self) -> Result<Vec<Response>, Error>
The cometd connect method. It will hang for a response from the server according
to the timeout provided to the cometd client.
If one or several sucess responses are returned to the request, it will return a Vec
containing those responses.
If an errored response is received but an advice is provided by the server, the client
will try to follow this advice and re-attemp the connection. If the maximum number of retries
is reached and the response still does not succeed, it will return an error.
§Errors
The cometd server’s response could not be parsed. The cometd server returned a response that indicated an error and the request could not be retried or the maximum number of retries has been reached.
Sourcepub fn disconnect(&mut self) -> Result<Vec<Response>, Error>
pub fn disconnect(&mut self) -> Result<Vec<Response>, Error>
The cometd disconnect method.
If one or several sucess responses are returned to the request, it will return a Vec
containing those responses.
§Errors
The cometd server’s response could not be parsed. The cometd server returned a response that indicated an error and the request could not be retried or the maximum number of retries has been reached.
Sourcepub fn init(&mut self) -> Result<Vec<Response>, Error>
pub fn init(&mut self) -> Result<Vec<Response>, Error>
Init the cometd client. It will attempt to establish a handshake between the client and the server so it can make further requests.
Sourcepub fn subscribe(&mut self, subscription: &str) -> Result<Vec<Response>, Error>
pub fn subscribe(&mut self, subscription: &str) -> Result<Vec<Response>, Error>
The cometd subscribe method. It will ask the server to subscribe to a certain channel and therefore
be updated when something is posted on this channel.
If one or several sucess responses are returned to the request, it will return a Vec
containing those responses.
If an errored response is received but an advice is provided by the server, the client
will try to follow this advice and re-attemp the connection. If the maximum number of retries
is reached and the response still does not succeed, it will return an error.
§Errors
The cometd server’s response could not be parsed. The cometd server returned a response that indicated an error and the request could not be retried or the maximum number of retries has been reached.
Sourcepub fn unsubscribe(
&mut self,
subscription: &str,
) -> Result<Vec<Response>, Error>
pub fn unsubscribe( &mut self, subscription: &str, ) -> Result<Vec<Response>, Error>
The cometd subscribe method. It will ask the server to unsubscribe from a certain channel and therefore
strop being updated when something is posted on this channel.
If one or several sucess responses are returned to the request, it will return a Vec
containing those responses.
If an errored response is received but an advice is provided by the server, the client
will try to follow this advice and re-attemp the connection. If the maximum number of retries
is reached and the response still does not succeed, it will return an error.
§Errors
The cometd server’s response could not be parsed. The cometd server returned a response that indicated an error and the request could not be retried or the maximum number of retries has been reached.
Sourcepub fn publish(
&mut self,
channel: &str,
data: impl Serialize,
) -> Result<Vec<Response>, Error>
pub fn publish( &mut self, channel: &str, data: impl Serialize, ) -> Result<Vec<Response>, Error>
The cometd plublish method. It will ask the server to publish a message to a certain channel.
If one or several sucess responses are returned to the request, it will return a Vec
containing those responses.
If an errored response is received but an advice is provided by the server, the client
will try to follow this advice and re-attemp the connection. If the maximum number of retries
is reached and the response still does not succeed, it will return an error.
§Errors
The cometd server’s response could not be parsed. The cometd server returned a response that indicated an error and the request could not be retried or the maximum number of retries has been reached.
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more