IntoCache

Trait IntoCache 

Source
pub trait IntoCache: Cacheable {
    // Provided method
    fn into_cache<A>(self, upstream: &Addr<A>) -> QueryCache<A, Self>
       where A: Actor,
             Self: Message + Send + Sized,
             Self::Result: MessageResponse<A, Self> + Send + 'static { ... }
}
Expand description

Trait describes coversion from any actix::Message into QueryCache message.

Provided Methods§

Source

fn into_cache<A>(self, upstream: &Addr<A>) -> QueryCache<A, Self>
where A: Actor, Self: Message + Send + Sized, Self::Result: MessageResponse<A, Self> + Send + 'static,

Helper method to convert Message into QueryCache message.

§Examples
use actix::prelude::*;
use hitbox_actix::prelude::*;
use serde::Serialize;

struct Upstream;

impl Actor for Upstream {
    type Context = Context<Self>;
}

#[derive(Cacheable, Serialize, Message, Debug, PartialEq)]
#[rtype(result = "()")]
struct QueryNothing {
    id: Option<i32>,
}

#[actix_rt::main]
async fn main() {
    let upstream = Upstream.start();
    let query = QueryNothing { id: Some(1) }
        .into_cache(&upstream);
}

Implementors§