Struct harmony_rust_sdk::client::Client [−][src]
Client implementation for Harmony.
Implementations
impl Client
[src]
pub async fn new(
homeserver_url: Url,
session: Option<Session>
) -> ClientResult<Self>
[src]
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
.
Example
let client = Client::new("https://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>
Send a request.
Example
client .request::<ProfileUpdateRequest, _, _>( ProfileUpdate::default() .new_status(UserStatus::OnlineUnspecified) .new_is_bot(true), ) .await?;
pub fn auth_status(&self) -> AuthStatus
[src]
pub fn homeserver_url(&self) -> &Url
[src]
Get the stored homeserver URL.
Example
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.
Example
assert_eq!(client.make_hmc("404"), Hmc::new("chat.harmonyapp.io:2289", "404"));
pub async fn begin_auth(&self) -> ClientResult<()>
[src]
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
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
client.begin_auth().await?; // 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(
&self,
subscriptions: Vec<EventSource>
) -> ClientResult<EventsSocket>
[src]
&self,
subscriptions: Vec<EventSource>
) -> ClientResult<EventsSocket>
Subscribe to events coming from specified event sources.
Example
// 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
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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, 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> Same<T> for T
type Output = T
Should always be Self
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>,