rustybook-messenger 0.2.1

Messenger client for Rustybook
Documentation
use crate::client::MessengerClient;
#[cfg(feature = "cache")]
use crate::client::models::{
    Message,
    User,
};

#[derive(Clone)]
pub struct Context {
    client: MessengerClient,
}

impl Context {
    pub fn new(client: MessengerClient) -> Self {
        Self { client }
    }

    /// Returns the Rustybook client bound to this handler context.
    pub fn client(&self) -> &MessengerClient {
        &self.client
    }

    /// Returns the cached current user info, if available.
    #[cfg(feature = "cache")]
    pub async fn user(&self) -> Option<User> {
        self.client.inner.cache.user()
    }

    /// Returns cached message events.
    #[cfg(feature = "cache")]
    pub async fn messages(&self) -> Vec<Message> {
        self.client.inner.cache.messages()
    }
}