[−][src]Struct harmony_rust_sdk::client::Client
Client implementation for Harmony.
Implementations
impl Client
[src]
pub async fn new(
homeserver_url: Uri,
session: Option<Session>
) -> ClientResult<Self>
[src]
homeserver_url: Uri,
session: Option<Session>
) -> ClientResult<Self>
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]
&self,
request: IntoReq
) -> ClientResult<Resp>
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]
&self,
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.
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]
&self
) -> ClientResult<impl Stream<Item = ClientResult<AuthStep>> + Send + Sync>
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]
&self,
subscriptions: Vec<EventSource>
) -> ClientResult<(impl Stream<Item = ClientResult<Event>> + Send + Sync, impl Sink<EventSource, Error = impl Debug> + Send + Sync)>
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
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,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoRequest<T> for T
[src]
pub fn into_request(self) -> Request<T>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,