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

pub struct Client { /* fields omitted */ }

Client implementation for Harmony.


impl Client[src]

pub async fn new(
    homeserver_url: Url,
    session: Option<Session>
) -> ClientResult<Self>

Create a new Client from a homeserver Url (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.


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

pub async fn request<Req: ClientRequest<Resp>, Resp, IntoReq: Into<Req>>(
    request: IntoReq
) -> ClientResult<Resp>

Send a request.


 .request::<ProfileUpdateRequest, _, _>(

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

Get the current auth status.



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

Get the stored homeserver URL.


assert_eq!(&client.homeserver_url().to_string(), "https://chat.harmonyapp.io:2289/");

pub fn make_hmc(&self, id: impl ToString) -> Hmc[src]

Makes an HMC with homeserver's authority and the given ID.


assert_eq!(client.make_hmc("404"), Hmc::new("chat.harmonyapp.io:2289", "404"));

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

Start an authentication session.


// Do auth stuff here

pub async fn next_auth_step(
    response: AuthStepResponse
) -> ClientResult<Option<AuthStep>>

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.


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.


// Call next step and whatnot here
// Oops, user wants to do something else, lets go back
let prev_step = client.prev_auth_step().await?;
// Do more auth stuff here

pub async fn subscribe_events(
    subscriptions: Vec<EventSource>
) -> ClientResult<EventsSocket>

Subscribe to events coming from specified event sources.


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

impl !RefUnwindSafe for Client[src]

impl Send for Client[src]

impl Sync for Client[src]

impl Unpin for Client[src]

impl !UnwindSafe for Client[src]

Blanket Implementations

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

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

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

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

impl<T> IntoRequest<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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