Struct MatrixClient

Source
pub struct MatrixClient { /* private fields */ }
Expand description

A connection to a Matrix homeserver, using the hyper crate.

Implementations§

Source§

impl MatrixClient

Source

pub fn new_from_access_token( token: &str, url: &str, hdl: &Handle, ) -> impl Future<Item = Self, Error = MatrixError>

Source

pub fn login_password( username: &str, password: &str, url: &str, hdl: &Handle, ) -> impl Future<Item = Self, Error = MatrixError>

Log in to a Matrix homeserver with a username and password, and return a client object.

§Parameters
  • username: the username of the account to use (NB: not a MXID)
  • password: the password of the account to use
  • url: the URL of the homeserver
  • hdl: Tokio reactor handle
Source

pub fn as_register_user( &mut self, user_id: String, ) -> impl Future<Item = (), Error = MatrixError>

(for Application Services) Register a user with the given user_id.

Source

pub fn as_new( url: String, user_id: String, as_token: String, hdl: &Handle, ) -> MatrixResult<Self>

(for Application Services) Make a new AS client.

§Parameters
  • url: homeserver URL
  • user_id: user ID to impersonate (can be changed later, using alter_user_id)
  • as_token: application service token
  • hdl: Tokio reactor handle
Source

pub fn as_alter_user_id(&mut self, user_id: String)

(for Application Services) Alter the user ID which this client is masquerading as.

Source

pub fn get_hyper(&self) -> MatrixHyper

Convenience method that clones the MatrixClient’s underlying HTTP client. Useful if you don’t want to have to make your own HTTP client, and need one for some quick’n’dirty task.

Trait Implementations§

Source§

impl Clone for MatrixClient

Source§

fn clone(&self) -> MatrixClient

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for MatrixClient

Source§

fn drop(&mut self)

Invalidates our access token, so we don’t have millions of devices. Also sets us as offline.

Source§

impl MatrixRequestable for MatrixClient

Source§

type Txnid = Uuid

The type of the transaction ID returned by get_txnid().
Source§

type ResponseBody = Chunk

The type of the HTTP response body.
Source§

type ResponseBodyFuture = MxClientResponseBodyFuture

The type of the future returned as a HTTP response body. Read more
Source§

type SendRequestFuture = MxClientSendRequestFuture

The type of the future returned by send_request(). Read more
Source§

fn get_url(&self) -> Cow<'_, str>

Gets the client’s URL.
Source§

fn get_access_token(&self) -> Cow<'_, str>

Gets the client’s access token.
Source§

fn get_txnid(&mut self) -> Uuid

Gets a new transaction ID. Read more
Source§

fn get_user_id(&self) -> Cow<'_, str>

Gets the client’s user ID.
Source§

fn is_as(&self) -> bool

Checks whether the client is an Application Service (AS).
Source§

fn send_request(&mut self, req: Request<Vec<u8>>) -> Self::SendRequestFuture

Send an arbitrary HTTP request to the Matrix homeserver.
Source§

fn typed_api_call<T>( &mut self, req: Request<Vec<u8>>, discard: bool, ) -> TypedApiResponse<T, Self::SendRequestFuture, Self::ResponseBodyFuture>
where T: DeserializeOwned + 'static,

Send an arbitrary HTTP request to the Matrix homeserver, and deserialize the JSON response to a value of type T. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.