GroupRest

Struct GroupRest 

Source
pub struct GroupRest<'a> {
    pub client: &'a RestClient,
}

Fields§

§client: &'a RestClient

Implementations§

Source§

impl<'a> GroupRest<'a>

Source

pub async fn create_group( &self, user_ids: Vec<u64>, ) -> Result<Channel, Box<dyn Error + Send + Sync>>

Examples found in repository?
examples/group.rs (line 15)
4async fn main() {
5    pretty_env_logger::init();
6
7    let token = std::fs::read_to_string("token.txt").unwrap();
8
9    let client = RestClient::connect(token, None, None).await.unwrap();
10
11    println!("API Version: {}", client.api_version);
12
13    let channel = client
14        .group()
15        .create_group(vec![1258065464966254600, 901809620165722112])
16        .await
17        .unwrap();
18
19    for user in &channel.recipients.unwrap() {
20        client
21            .group()
22            .kick_user_from_group(channel.id, user.id)
23            .await
24            .unwrap();
25    }
26
27    client
28        .group()
29        .rename_group(channel.id, "New Group Name")
30        .await
31        .unwrap();
32
33    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
34
35    client.group().leave_group(channel.id, false).await.unwrap();
36}
Source

pub async fn add_user_to_group( &self, channel_id: u64, user_id: u64, ) -> Result<(), Box<dyn Error + Send + Sync>>

Source

pub async fn kick_user_from_group( &self, channel_id: u64, user_id: u64, ) -> Result<(), Box<dyn Error + Send + Sync>>

Examples found in repository?
examples/group.rs (line 22)
4async fn main() {
5    pretty_env_logger::init();
6
7    let token = std::fs::read_to_string("token.txt").unwrap();
8
9    let client = RestClient::connect(token, None, None).await.unwrap();
10
11    println!("API Version: {}", client.api_version);
12
13    let channel = client
14        .group()
15        .create_group(vec![1258065464966254600, 901809620165722112])
16        .await
17        .unwrap();
18
19    for user in &channel.recipients.unwrap() {
20        client
21            .group()
22            .kick_user_from_group(channel.id, user.id)
23            .await
24            .unwrap();
25    }
26
27    client
28        .group()
29        .rename_group(channel.id, "New Group Name")
30        .await
31        .unwrap();
32
33    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
34
35    client.group().leave_group(channel.id, false).await.unwrap();
36}
Source

pub async fn transfer_group_ownership( &self, channel_id: u64, user_id: u64, ) -> Result<Channel, Box<dyn Error + Send + Sync>>

Source

pub async fn rename_group( &self, channel_id: u64, name: &str, ) -> Result<Channel, Box<dyn Error + Send + Sync>>

Examples found in repository?
examples/group.rs (line 29)
4async fn main() {
5    pretty_env_logger::init();
6
7    let token = std::fs::read_to_string("token.txt").unwrap();
8
9    let client = RestClient::connect(token, None, None).await.unwrap();
10
11    println!("API Version: {}", client.api_version);
12
13    let channel = client
14        .group()
15        .create_group(vec![1258065464966254600, 901809620165722112])
16        .await
17        .unwrap();
18
19    for user in &channel.recipients.unwrap() {
20        client
21            .group()
22            .kick_user_from_group(channel.id, user.id)
23            .await
24            .unwrap();
25    }
26
27    client
28        .group()
29        .rename_group(channel.id, "New Group Name")
30        .await
31        .unwrap();
32
33    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
34
35    client.group().leave_group(channel.id, false).await.unwrap();
36}
Source

pub async fn leave_group( &self, channel_id: u64, silent: bool, ) -> Result<Channel, Box<dyn Error + Send + Sync>>

Examples found in repository?
examples/group.rs (line 35)
4async fn main() {
5    pretty_env_logger::init();
6
7    let token = std::fs::read_to_string("token.txt").unwrap();
8
9    let client = RestClient::connect(token, None, None).await.unwrap();
10
11    println!("API Version: {}", client.api_version);
12
13    let channel = client
14        .group()
15        .create_group(vec![1258065464966254600, 901809620165722112])
16        .await
17        .unwrap();
18
19    for user in &channel.recipients.unwrap() {
20        client
21            .group()
22            .kick_user_from_group(channel.id, user.id)
23            .await
24            .unwrap();
25    }
26
27    client
28        .group()
29        .rename_group(channel.id, "New Group Name")
30        .await
31        .unwrap();
32
33    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
34
35    client.group().leave_group(channel.id, false).await.unwrap();
36}

Auto Trait Implementations§

§

impl<'a> Freeze for GroupRest<'a>

§

impl<'a> !RefUnwindSafe for GroupRest<'a>

§

impl<'a> Send for GroupRest<'a>

§

impl<'a> Sync for GroupRest<'a>

§

impl<'a> Unpin for GroupRest<'a>

§

impl<'a> !UnwindSafe for GroupRest<'a>

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> 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, 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T