Struct wamp_async::Client[][src]

pub struct Client<'a> { /* fields omitted */ }

Allows interaction as a client with a WAMP server

Implementations

impl<'a> Client<'a>[src]

pub async fn connect<T: AsRef<str>>(
    uri: T,
    cfg: Option<ClientConfig>
) -> Result<(Client<'a>, (GenericFuture<'a>, Option<UnboundedReceiver<GenericFuture<'a>>>)), WampError>
[src]

Connects to a WAMP server using the specified protocol

Note

On success, this function returns :

  • Client : Used to interact with the server
  • Main event loop Future : This MUST be spawned by the caller (e.g using tokio::spawn())
  • RPC event queue : If you register RPC endpoints, you MUST spawn a seperate task to also handle these events

To customize parmeters used for the connection, see the ClientConfig struct

pub async fn join_realm<T: Into<String>>(
    &mut self,
    realm: T
) -> Result<(), WampError>
[src]

Attempts to join a realm and start a session with the server.

  • realm - A name of the WAMP realm

pub async fn join_realm_with_authentication<Realm, AuthenticationId, AuthenticationChallengeHandler, AuthenticationChallengeHandlerResponse>(
    &mut self,
    realm: Realm,
    authentication_methods: Vec<AuthenticationMethod>,
    authentication_id: AuthenticationId,
    on_challenge_handler: AuthenticationChallengeHandler
) -> Result<(), WampError> where
    Realm: Into<String>,
    AuthenticationId: Into<String>,
    AuthenticationChallengeHandler: Fn(AuthenticationMethod, WampDict) -> AuthenticationChallengeHandlerResponse + Send + Sync + 'a,
    AuthenticationChallengeHandlerResponse: Future<Output = Result<AuthenticationChallengeResponse, WampError>> + Send + 'a, 
[src]

Attempts to join a realm and start a session with the server.

  • realm - A name of the WAMP realm
  • authentication_methods - A set of all the authentication methods the client will support
  • authentication_id - An authentication ID (e.g. username) the client wishes to authenticate as. It is required for non-anynomous authentication methods.
  • on_challenge_handler - An authentication handler function
client
    .join_realm_with_authentication(
        "realm1",
        vec![wamp_async::AuthenticationMethod::Ticket],
        "username",
        |_authentication_method, _extra| async {
            Ok(wamp_async::AuthenticationChallengeResponse::with_signature(
                "password".into(),
            ))
        },
    )
    .await?;

pub async fn leave_realm(&mut self) -> Result<(), WampError>[src]

Leaves the current realm and terminates the session with the server

pub async fn subscribe<T: AsRef<str>>(
    &self,
    topic: T
) -> Result<(WampId, UnboundedReceiver<(WampId, Option<WampArgs>, Option<WampKwArgs>)>), WampError>
[src]

Subscribes to events for the specifiec topic

This function returns a subscription ID (required to unsubscribe) and the receive end of a channel for events published on the topic.

pub async fn unsubscribe(&self, sub_id: WampId) -> Result<(), WampError>[src]

Unsubscribes to a previously subscribed topic

pub async fn publish<T: AsRef<str>>(
    &self,
    topic: T,
    arguments: Option<WampArgs>,
    arguments_kw: Option<WampKwArgs>,
    acknowledge: bool
) -> Result<Option<WampId>, WampError>
[src]

Publishes an event on a specific topic

The caller can set acknowledge to true to receive unique IDs from the server for each published event.

pub async fn register<T, F, Fut>(
    &self,
    uri: T,
    func_ptr: F
) -> Result<WampId, WampError> where
    T: AsRef<str>,
    F: Fn(Option<WampArgs>, Option<WampKwArgs>) -> Fut + Send + Sync + 'a,
    Fut: Future<Output = Result<(Option<WampArgs>, Option<WampKwArgs>), WampError>> + Send + 'a, 
[src]

Register an RPC endpoint. Upon succesful registration, a registration ID is returned (used to unregister) and calls received from the server will generate a future which will be sent on the rpc event channel returned by the call to event_loop()

pub async fn unregister(&self, rpc_id: WampId) -> Result<(), WampError>[src]

Unregisters an RPC endpoint

pub async fn call<T: AsRef<str>>(
    &self,
    uri: T,
    arguments: Option<WampArgs>,
    arguments_kw: Option<WampKwArgs>
) -> Result<(Option<WampArgs>, Option<WampKwArgs>), WampError>
[src]

Calls a registered RPC endpoint on the server

pub fn get_cur_status(&mut self) -> &ClientState[src]

Returns the current client status

pub fn is_connected(&mut self) -> bool[src]

Returns whether we are connected to the server or not

pub async fn block_until_disconnect(&mut self) -> &ClientState[src]

Blocks the caller until the connection with the server is terminated

pub async fn disconnect(self)[src]

Cleanly closes a connection with the server

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Client<'a>

impl<'a> Send for Client<'a>

impl<'a> Sync for Client<'a>

impl<'a> Unpin for Client<'a>

impl<'a> !UnwindSafe for Client<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,