pub trait Update {
    type Output;

    fn update<'async_trait>(
        self
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, DotError>> + 'async_trait>>
    where
        Self: 'async_trait
; }
Expand description

Update trait specifies if something can be updated or not.

By default, only Threads, Catalogs, and Boards can be updated.

Usecase Example

use dot4ch::{Client, thread::Thread, Update};

let client = Client::new();

let thread = Thread::new(&client, "g", 76759434).await.unwrap();

/* --- do some work with the thread */

// time to update
let thread = thread.update().await.unwrap();

println!("{:?}", thread);

Implementation Example

struct Something(i32);

impl Update for Something {
    // the output this trait should produce
    type Output = ();
     
    async fn update(mut self) -> Result<Self::Output, DotError> {
        self.0 += 32;
        Ok(())
    }
}

 
let mut x = Something(21);
x.update();
assert_eq!(x.0, 53);

Required Associated Types

The type of the output.

Required Methods

Returns the updated self type.

Implementors