rocketchat

Crates.iorocketchat
lib.rsrocketchat
version0.4.1
sourcesrc
created_at2022-10-17 18:48:23.24903
updated_at2022-11-01 20:02:35.054727
descriptionRocket.Chat API Implemented in Rust
homepagehttps://github.com/karpa4o4/rocketchat
repositoryhttps://github.com/karpa4o4/rocketchat
max_upload_size
id690307
size14,346
Denis Gavrilyuk (karpa4o4)

documentation

https://docs.rs/rocketchat/latest/rocketchat

README

rocketchat

Rust API wrapper for the RocketChat API

crates.io MIT

Example

The library uses asynchronous HTTP client reqwest, so your Cargo.toml could look like this:

rocketchat = "0.4.0"
tokio = { version = "1", features = ["full"] }

When calling methods, you need to pass settings that can be created as follows:

Using username and password

use rocketchat::{LoginSettings, Settings};

let settings = Settings::Login(LoginSettings {
    username: "chuck_norris".to_string(),
    password: "supersecret".to_string(),
    domain: "https://mydomain.com".to_string(),
});

Using auth token and user ID

use rocketchat::{AuthSettings, Settings};

let settings = Settings::Auth(AuthSettings {
    auth_token: "some_auth_token".to_string(),
    user_id: "some_user_id".to_string(),
    domain: "https://mydomain.com".to_string(),
});

Available API methods

Post Message

use rocketchat::methods::PostMessageMethod;

let result = PostMessageMethod {
    settings: &settings,
    room_id: "#channel".to_string(),
    text: Some("Some message with star emoji :star:".to_string()),
    ..Default::default()
}.call().await;

Channel Create

use rocketchat::methods::ChannelCreateMethod;

let result = ChannelCreateMethod {
    settings: &settings,
    name: "some-channel".to_string(),
    members: Some(vec!["rocket.cat".to_string()]),
    ..Default::default()
}.call().await;

License

MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Commit count: 23

cargo fmt