Struct mattermost_api::client::Mattermost[][src]

pub struct Mattermost { /* fields omitted */ }
Expand description

Struct to interact with a Mattermost instance API.

Use the new function to create an instance of this struct.

Implementations

Create a new instance of the struct to interact with the instance API.

The instance_url variable should be the root URL of your Mattermost instance.

Example
use mattermost_api::prelude::*;
let auth = AuthenticationData::from_password("you@example.com", "password");
let api = Mattermost::new("https://your-mattermost-instance.com", auth);

Get a session token from the stored login_id and password. Required when using login_id and password authentication, before making any calls to the instance API.

Does nothing if the AuthenticationData this struct instance was created with used a personal access token.

Example
use mattermost_api::prelude::*;
let auth = AuthenticationData::from_password("you@example.com", "password");
let mut api = Mattermost::new("https://your-mattermost-instance.com", auth);
api.store_session_token().await.unwrap();

Make a query to the Mattermost instance API.

This method is “raw” in that the calling code must supply the method, query parameters, body, and a struct for the shape of the data returned (or serde_json::Value for “dynamic” data).

Developers are encouraged to look for a specific endpoint function that is for the API endpoint that is desired, but this function is exposed to calling code so that this library can be more flexible.

Connect to the websocket API on the instance.

This method loops, sending messages received from the websocket connection to the passed handler. The authentication handshake is handled with the connection is made, but otherwise no handling of messages is currently implemented.

This function is likely to experience a great deal of change soon.

Example
use async_trait::async_trait;
use mattermost_api::prelude::*;

struct Handler {}

#[async_trait]
impl WebsocketHandler for Handler {
    async fn callback(&self, message: WebsocketEvent) {
        println!("{:?}", message);
    }
}

let auth = AuthenticationData::from_password("you@example.com", "password");
let mut api = Mattermost::new("https://your-mattermost-instance.com", auth);
api.store_session_token().await.unwrap();
api.connect_to_websocket(Handler {}).await.unwrap();

Get a team’s information.

Get information for a team by its name,

List teams that are open or, if the user has the “manage_system” permission, exist.

Get the number of unread messages and mentions for all member teams of the user.

Get the number of unread messages and mentions for the specific team the user is in.

Requires either the “read_channel” or “edit_other_users” permission.

Get all channels on the instance.

Requires the “manage_system” permission.

Get a channel’s information.

Requires the “read_channel” permission for that channel.

Get public channels’ information.

Requires the “list_team_channels” permission.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more