[][src]Struct harmony_rust_sdk::client::Client

pub struct Client { /* fields omitted */ }

Client implementation for Harmony.

Implementations

impl Client[src]

pub async fn new(
    homeserver_url: Uri,
    session: Option<Session>
) -> ClientResult<Self>
[src]

Create a new Client from a homeserver Uri (URL) and an (optional) session.

If port is not specified in the URL, this will add the default port 2289 to it. If scheme is not specified, this will assume the scheme is https.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;

pub async fn request<Req: ClientRequest<Resp>, Resp, IntoReq: Into<Req>>(
    &self,
    request: IntoReq
) -> ClientResult<Resp>
[src]

Sends a request.

pub fn auth_status(&self) -> AuthStatus[src]

Get the current auth status.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
assert!(!client.auth_status().is_authenticated());

pub fn homeserver_url(&self) -> &Uri[src]

Get the stored homeserver URL.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
assert_eq!(&client.homeserver_url().to_string(), "https://chat.harmonyapp.io:2289/");

pub async fn begin_auth(&self) -> ClientResult<()>[src]

Start an authentication session.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
client.begin_auth().await?;
// Do auth stuff here

pub async fn next_auth_step(
    &self,
    response: AuthStepResponse
) -> ClientResult<Option<AuthStep>>
[src]

Request the next authentication step from the server.

Returns Ok(None) if authentication was completed. Returns Ok(Some(AuthStep)) if extra step is requested from the server.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
client.begin_auth().await?;
let next_step = client.next_auth_step(AuthStepResponse::Initial).await?;
// Do more auth stuff here

pub async fn prev_auth_step(&self) -> ClientResult<AuthStep>[src]

Go back to the previous authentication step.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
client.begin_auth().await?;
let next_step = client.next_auth_step(AuthStepResponse::Initial).await?;
let prev_step = client.prev_auth_step().await?;
// Do more auth stuff here

pub async fn auth_stream(
    &self
) -> ClientResult<impl Stream<Item = ClientResult<AuthStep>> + Send + Sync>
[src]

Begin an authentication steps stream for the current authentication session.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
client.begin_auth().await?;
let auth_steps_stream = client.auth_stream().await?;
// Do auth stuff here

pub async fn subscribe_events(
    &self,
    subscriptions: Vec<EventSource>
) -> ClientResult<(impl Stream<Item = ClientResult<Event>> + Send + Sync, impl Sink<EventSource, Error = impl Debug> + Send + Sync)>
[src]

Subscribe to events coming from specified event sources.

Example

let client = Client::new("chat.harmonyapp.io:2289".parse().unwrap(), None).await?;
// Auth here
let event_stream = client.subscribe_events(vec![EventSource::Homeserver, EventSource::Action]).await?;
// Do more auth stuff here

Trait Implementations

impl Clone for Client[src]

impl Debug for Client[src]

Auto Trait Implementations

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> Instrument for T[src]

impl<T> Instrument for T[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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>, 

impl<T> WithSubscriber for T[src]