Struct glitch_in_the_matrix::MatrixClient
[−]
[src]
pub struct MatrixClient { /* fields omitted */ }
A connection to a Matrix homeserver.
Methods
impl MatrixClient
[src]
fn login(
username: &str,
password: &str,
url: &str,
hdl: &Handle
) -> MatrixFuture<Self>
username: &str,
password: &str,
url: &str,
hdl: &Handle
) -> MatrixFuture<Self>
Log in to a Matrix homeserver, and return a client object.
fn join(&mut self, roomid: &str) -> MatrixFuture<JoinReply>
Join a room by identifier or alias.
fn update_presence(&mut self, p: Presence) -> MatrixFuture<()>
Update our presence status.
fn read_receipt(&mut self, roomid: &str, eventid: &str) -> MatrixFuture<()>
Send a read receipt for a given event ID.
fn send(&mut self, roomid: &str, msg: Message) -> MatrixFuture<SendReply>
Send a message to a room ID.
fn send_simple<T: Into<String>>(
&mut self,
roomid: &str,
msg: T
) -> MatrixFuture<SendReply>
&mut self,
roomid: &str,
msg: T
) -> MatrixFuture<SendReply>
Wrapper function that sends a Message::Notice
with the specified unformatted text
to the given room ID. Provided for convenience purposes.
fn send_html<T: Into<String>, U: Into<Option<String>>>(
&mut self,
roomid: &str,
msg: T,
unformatted: U
) -> MatrixFuture<SendReply>
&mut self,
roomid: &str,
msg: T,
unformatted: U
) -> MatrixFuture<SendReply>
Wrapper function that sends a Message::Notice
with the specified HTML-formatted text
(and accompanying unformatted text, if given) to the given room ID.
fn upload<T: Into<Body>>(
&mut self,
data: T,
ct: ContentType
) -> MatrixFuture<UploadReply>
&mut self,
data: T,
ct: ContentType
) -> MatrixFuture<UploadReply>
Upload some data (convertible to a Body
) of a given ContentType
, like an image.
Body
is accessible via the http
module. See the documentation there
for a complete reference of what implements Into<Body>
- a quick
shortlist: Vec<u8>
, &'static [u8]
(not &'a [u8]
, sadly), String
,
&'static str
.
ContentType
is accessible via the http
module. See the documentation
there for more information on how to use it.
fn user_id(&self) -> &str
Get the client's MXID.
fn get_sync_stream(&self) -> SyncStream
Get a SyncStream
, a Stream
used to obtain replies to the /sync
API.
This SyncStream
is independent from the original MatrixClient
, and
does not borrow from it in any way.
fn req<T>(
&mut self,
meth: Method,
endpoint: &str,
params: Vec<String>,
body: Option<Body>
) -> MatrixFuture<T> where
T: Deserialize + 'static,
&mut self,
meth: Method,
endpoint: &str,
params: Vec<String>,
body: Option<Body>
) -> MatrixFuture<T> where
T: Deserialize + 'static,
Make an arbitrary request to the Matrix API.
Parameters
meth
: method (exported in thehttp
module).endpoint
: API endpoint, without/_matrix/client/r0
, e.g./sync
.params
: vector of parameters in the URL-escaped forma=b
(tacked on to the end of the request URL).<T>
: type that the Matrix API returns (must implementDeserialize
, e.g.SyncReply
).
fn discarding_req(
&mut self,
meth: Method,
endpoint: &str,
params: Vec<String>,
body: Option<Body>
) -> MatrixFuture<()>
&mut self,
meth: Method,
endpoint: &str,
params: Vec<String>,
body: Option<Body>
) -> MatrixFuture<()>
Like req()
, but uses send_discarding_request()
instead.
fn get_request_for(
&self,
meth: Method,
endpoint: &str,
params: Vec<String>,
body: Option<Body>
) -> MatrixResult<Request>
&self,
meth: Method,
endpoint: &str,
params: Vec<String>,
body: Option<Body>
) -> MatrixResult<Request>
Like req()
, but doesn't actually make the request.
Errors
Errors if your endpoint
and params
result in an invalid Uri
.
fn send_request<T>(&mut self, req: Request) -> MatrixFuture<T> where
T: Deserialize + 'static,
T: Deserialize + 'static,
Sends an arbitrary Request
to the Matrix homeserver, like one
generated by get_request_for()
.
fn send_discarding_request(&mut self, req: Request) -> MatrixFuture<()>
Like send_request()
, but discards the return value that the Matrix
homeserver sends back.
Trait Implementations
impl Drop for MatrixClient
[src]
fn drop(&mut self)
Invalidates our access token, so we don't have millions of devices. Also sets us as offline.