Struct OctopipesClient

Source
pub struct OctopipesClient { /* private fields */ }
Expand description

§OctopipesClient

OctopipesClient is a container for an Octopipes Client

Implementations§

Source§

impl OctopipesClient

Source

pub fn new( client_id: String, cap_pipe: String, version: OctopipesProtocolVersion, ) -> OctopipesClient

§OctopipesClient Constructor

new is constructor for OctopipesClient. OctopipesClient is actually a wrapper for a Client

Source

pub fn loop_start(&mut self) -> Result<(), OctopipesError>

§loop_start

loop_start starts the client loop thread which checks if new messages are available

Source

pub fn loop_stop(&mut self) -> Result<(), OctopipesError>

§loop_stop

loop_stop stops the client loop thread

Source

pub fn subscribe( &mut self, subscription_list: &Vec<String>, ) -> Result<OctopipesCapError, OctopipesError>

§subscribe

subscribe subscribe to Octopipes server; the client will subscribe to the groups described in the subscription_list

Source

pub fn unsubscribe(&mut self) -> Result<(), OctopipesError>

§unsubscribe

unsubscribe unsubscribe from Octopipes server; if thread is running it will be stopped

Source

pub fn send(&self, remote: &String, data: Vec<u8>) -> Result<(), OctopipesError>

§send

send sends a message to a certain remote

Source

pub fn send_ex( &self, remote: &String, data: Vec<u8>, ttl: u8, options: OctopipesOptions, ) -> Result<(), OctopipesError>

§send_ex

send_ex sends a message to a certain remote with extended options

Source

pub fn get_next_message( &self, ) -> Result<Option<OctopipesMessage>, OctopipesError>

§get_next_message

get_next_message Gets the next available message on the receiver If a message is available Ok(message) is returned If no message is available Ok(None) is returned If there was an error while reading inbox, Err(OctopipesError) is returned

Source

pub fn get_all_message(&self) -> Result<Vec<OctopipesMessage>, OctopipesError>

§get_all_message

get_all_message Gets all the available messages on the receiver If there was no error while reading the inbox a vector with all the messages is returned (could have length 0) If there was an error while reading inbox, Err(OctopipesError) is returned

Source

pub fn set_on_received_callback( &mut self, callback: fn(Result<&OctopipesMessage, &OctopipesError>), )

§set_on_received_callback

set_on_received_callback sets the function to call on message received

Source

pub fn set_on_sent_callback(&mut self, callback: fn(&OctopipesMessage))

§set_on_sent_callbacl

set_on_sent_callbacl sets the function to call when a message is sent

Source

pub fn set_on_subscribed(&mut self, callback: fn())

§set_on_subscribed

set_on_subscribed sets the function to call on a successful subscription to the Octopipes Server

Source

pub fn set_on_unsubscribed(&mut self, callback: fn())

§set_on_unsubscribed

set_on_unsubscribed sets the function to call on a successful unsubscription from Octopipes server

Trait Implementations§

Source§

impl Drop for OctopipesClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.