-
I have a question about redis adapter let client = redis::Client::open("redis://127.0.0.1:6379?protocol=resp3")?;
let adapter = RedisAdapterCtr::new_with_redis(&client).await.expect("redis adapter error");
let (
layer,
io,
) = SocketIo::builder()
.with_parser(ParserConfig::msgpack())
.with_adapter::<RedisAdapter<_>>(adapter)
.build_layer(); layer for now is type "SocketIoLayer<CustomRedisAdapter<Emitter, RedisDriver>>" and i want keep io and pass layer to other function e.g pub struct AppState {
pub io: Arc<SocketIo<CustomRedisAdapter<Emitter, RedisDriver>>>,
}
let app_state = Arc::new(AppState {
io: Arc::new(io),
}); but i can't use Emitter in socketioxide pls help me |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Currently, your only solution is to make struct AppState<A> {
pub io: SocketIo<A>,
} Indeed the |
Beta Was this translation helpful? Give feedback.
-
pub async fn start<A>(app_state: &Arc<AppState<A>>, layer: SocketIoLayer<A>) -> Result<()>
where
A: Adapter + DefinedAdapter,
{
app_state.io.ns("/notification", notification::handle).await?; use A that perfect but it have to specify Adapter + DefinedAdapter because error
final issue, I can't use .await, Could you help me? |
Beta Was this translation helpful? Give feedback.
Currently, your only solution is to make
AppState
generic over the adapter:Indeed the
Emitter
type is not exported and it should be so you can specify a complete type.By the way, you don't need to put
SocketIo
behind anArc
it is already one.