pub struct RedisStorage<S> { /* private fields */ }
Available on crate feature redis-storage only.
Expand description

A dialogue storage based on Redis.

Implementations§

source§

impl<S> RedisStorage<S>

source

pub async fn open( url: impl IntoConnectionInfo, serializer: S ) -> Result<Arc<Self>, RedisStorageError<Infallible>>

Examples found in repository?
examples/db_remember.rs (line 41)
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
async fn main() {
    pretty_env_logger::init();
    log::info!("Starting DB remember bot...");

    let bot = Bot::from_env();

    let storage: MyStorage = if std::env::var("DB_REMEMBER_REDIS").is_ok() {
        RedisStorage::open("redis://127.0.0.1:6379", Bincode).await.unwrap().erase()
    } else {
        SqliteStorage::open("db.sqlite", Json).await.unwrap().erase()
    };

    let handler = Update::filter_message()
        .enter_dialogue::<Message, ErasedStorage<State>, State>()
        .branch(dptree::case![State::Start].endpoint(start))
        .branch(
            dptree::case![State::GotNumber(n)]
                .branch(dptree::entry().filter_command::<Command>().endpoint(got_number))
                .branch(dptree::endpoint(invalid_command)),
        );

    Dispatcher::builder(bot, handler)
        .dependencies(dptree::deps![storage])
        .enable_ctrlc_handler()
        .build()
        .dispatch()
        .await;
}

Trait Implementations§

source§

impl<S, D> Storage<D> for RedisStorage<S>where S: Send + Sync + Serializer<D> + 'static, D: Send + Serialize + DeserializeOwned + 'static, <S as Serializer<D>>::Error: Debug + Display,

§

type Error = RedisStorageError<<S as Serializer<D>>::Error>

source§

fn remove_dialogue( self: Arc<Self>, ChatId: ChatId ) -> BoxFuture<'static, Result<(), Self::Error>>

Removes a dialogue indexed by chat_id. Read more
source§

fn update_dialogue( self: Arc<Self>, ChatId: ChatId, dialogue: D ) -> BoxFuture<'static, Result<(), Self::Error>>

Updates a dialogue indexed by chat_id with dialogue.
source§

fn get_dialogue( self: Arc<Self>, ChatId: ChatId ) -> BoxFuture<'static, Result<Option<D>, Self::Error>>

Returns the dialogue indexed by chat_id.

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for RedisStorage<S>

§

impl<S> Send for RedisStorage<S>where S: Send,

§

impl<S> Sync for RedisStorage<S>where S: Sync,

§

impl<S> Unpin for RedisStorage<S>where S: Unpin,

§

impl<S> !UnwindSafe for RedisStorage<S>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Erasable for T

§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
§

const ACK_1_1_0: bool = true

Available on non-enforce_1_1_0_semantics only.
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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