Skip to content

Commit

Permalink
feat(socketio/state): StateCell alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Totodore committed Dec 9, 2023
1 parent f6e2827 commit 08077cd
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 78 deletions.
4 changes: 2 additions & 2 deletions socketioxide/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ pub struct Client<A: Adapter> {
pub(crate) config: Arc<SocketIoConfig>,
ns: RwLock<HashMap<Cow<'static, str>, Arc<Namespace<A>>>>,

state: Arc<dyn std::any::Any + Send + Sync>,
state: StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
}

impl<A: Adapter> Client<A> {
pub fn new(config: Arc<SocketIoConfig>, state: Arc<dyn std::any::Any + Send + Sync>) -> Self {
pub fn new(config: Arc<SocketIoConfig>, state: StateCell) -> Self {

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
Self {
config,
ns: RwLock::new(HashMap::new()),
Expand Down
27 changes: 6 additions & 21 deletions socketioxide/src/handler/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ use super::MakeErasedHandler;
/// A Type Erased [`ConnectHandler`] so it can be stored in a HashMap
pub(crate) type BoxedConnectHandler<A> = Box<dyn ErasedConnectHandler<A>>;
pub(crate) trait ErasedConnectHandler<A: Adapter>: Send + Sync + 'static {
fn call(
&self,
s: Arc<Socket<A>>,
auth: Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>,
);
fn call(&self, s: Arc<Socket<A>>, auth: Option<String>, state: &StateCell);

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
}

impl<A: Adapter, T, H> MakeErasedHandler<H, A, T>
Expand All @@ -87,12 +82,7 @@ where
T: Send + Sync + 'static,
{
#[inline(always)]
fn call(
&self,
s: Arc<Socket<A>>,
auth: Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>,
) {
fn call(&self, s: Arc<Socket<A>>, auth: Option<String>, state: &StateCell) {

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
self.handler.call(s, auth, state);
}
}
Expand All @@ -112,7 +102,7 @@ pub trait FromConnectParts<A: Adapter>: Sized {
fn from_connect_parts(
s: &Arc<Socket<A>>,
auth: &Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> Result<Self, Self::Error>;
}

Expand All @@ -123,12 +113,7 @@ pub trait FromConnectParts<A: Adapter>: Sized {
/// * See the [`extract`](super::extract) module doc for more details on available extractors.
pub trait ConnectHandler<A: Adapter, T>: Send + Sync + 'static {
/// Call the handler with the given arguments.
fn call(
&self,
s: Arc<Socket<A>>,
auth: Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>,
);
fn call(&self, s: Arc<Socket<A>>, auth: Option<String>, state: &StateCell);

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

#[doc(hidden)]
fn phantom(&self) -> std::marker::PhantomData<T> {
Expand Down Expand Up @@ -159,7 +144,7 @@ macro_rules! impl_handler_async {
&self,
s: Arc<Socket<A>>,
auth: Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>)
state: &StateCell)

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
{
$(
let $ty = match $ty::from_connect_parts(&s, &auth, state) {
Expand Down Expand Up @@ -195,7 +180,7 @@ macro_rules! impl_handler {
&self,
s: Arc<Socket<A>>,
auth: Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>)
state: &StateCell)

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
{
$(
let $ty = match $ty::from_connect_parts(&s, &auth, state) {
Expand Down
38 changes: 20 additions & 18 deletions socketioxide/src/handler/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ where
fn from_connect_parts(
_: &Arc<Socket<A>>,
auth: &Option<String>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Self::Error> {
auth.as_ref()
.map(|a| serde_json::from_str::<T>(a))
Expand All @@ -138,7 +138,7 @@ where
v: &mut serde_json::Value,
_: &mut Vec<Vec<u8>>,
_: &Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Self::Error> {
upwrap_array(v);
serde_json::from_value(v.clone()).map(Data)
Expand All @@ -157,7 +157,7 @@ where
fn from_connect_parts(
_: &Arc<Socket<A>>,
auth: &Option<String>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
let v: Result<T, serde_json::Error> = auth
.as_ref()
Expand All @@ -177,7 +177,7 @@ where
v: &mut serde_json::Value,
_: &mut Vec<Vec<u8>>,
_: &Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
upwrap_array(v);
Ok(TryData(serde_json::from_value(v.clone())))
Expand All @@ -191,7 +191,7 @@ impl<A: Adapter> FromConnectParts<A> for SocketRef<A> {
fn from_connect_parts(
s: &Arc<Socket<A>>,
_: &Option<String>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(SocketRef(s.clone()))
}
Expand All @@ -203,7 +203,7 @@ impl<A: Adapter> FromMessageParts<A> for SocketRef<A> {
_: &mut serde_json::Value,
_: &mut Vec<Vec<u8>>,
_: &Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(SocketRef(s.clone()))
}
Expand Down Expand Up @@ -248,7 +248,7 @@ impl<A: Adapter> FromMessage<A> for Bin {
_: serde_json::Value,
bin: Vec<Vec<u8>>,
_: Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(Bin(bin))
}
Expand All @@ -269,7 +269,7 @@ impl<A: Adapter> FromMessageParts<A> for AckSender<A> {
_: &mut serde_json::Value,
_: &mut Vec<Vec<u8>>,
ack_id: &Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(Self::new(s.clone(), *ack_id))
}
Expand Down Expand Up @@ -311,7 +311,7 @@ impl<A: Adapter> FromConnectParts<A> for crate::ProtocolVersion {
fn from_connect_parts(
s: &Arc<Socket<A>>,
_: &Option<String>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(s.protocol())
}
Expand All @@ -323,7 +323,7 @@ impl<A: Adapter> FromMessageParts<A> for crate::ProtocolVersion {
_: &mut serde_json::Value,
_: &mut Vec<Vec<u8>>,
_: &Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(s.protocol())
}
Expand All @@ -340,7 +340,7 @@ impl<A: Adapter> FromConnectParts<A> for crate::TransportType {
fn from_connect_parts(
s: &Arc<Socket<A>>,
_: &Option<String>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(s.transport_type())
}
Expand All @@ -352,7 +352,7 @@ impl<A: Adapter> FromMessageParts<A> for crate::TransportType {
_: &mut serde_json::Value,
_: &mut Vec<Vec<u8>>,
_: &Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
_: &StateCell,
) -> Result<Self, Infallible> {
Ok(s.transport_type())
}
Expand Down Expand Up @@ -411,10 +411,12 @@ impl<A: Adapter> FromDisconnectParts<A> for DisconnectReason {
/// println!("User count: {}", state.user_cnt());
/// });
pub struct State<T: Send + Sync + 'static> {
/// The state must be in an `Arc` because it is impossible to have lifetime on the extracted data.
state: Arc<dyn std::any::Any + Send + Sync>,
state: StateCell,
_marker: std::marker::PhantomData<T>,
}
/// The state must be in an `Arc` because it is impossible to have lifetime on the extracted data.
pub type StateCell = Arc<dyn std::any::Any + Send + Sync>;

impl<T: Send + Sync + 'static> std::ops::Deref for State<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -442,7 +444,7 @@ impl<A: Adapter, T: Send + Sync + 'static> FromConnectParts<A> for State<T> {
fn from_connect_parts(
_: &Arc<Socket<A>>,
_: &Option<String>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,
) -> Result<Self, StateNotFound> {
// SAFETY: This check is mandatory because later when the extractor is used,
// the state type is dereferenced without any checks
Expand All @@ -462,7 +464,7 @@ impl<A: Adapter, T: Send + Sync + 'static> FromMessageParts<A> for State<T> {
_: &mut Value,
_: &mut Vec<Vec<u8>>,
_: &Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,
) -> Result<Self, StateNotFound> {
if !state.is::<T>() {
return Err(StateNotFound);
Expand Down Expand Up @@ -494,14 +496,14 @@ mod tests {
fn extract_state_not_found() {
struct A;
struct B;
let b = Arc::new(B) as Arc<dyn std::any::Any + Send + Sync>;
let b = Arc::new(B) as StateCell;
State::<A>::from_connect_parts(&new_socket(), &None, &b).unwrap_err();
}

#[test]
fn extract_state_found() {
struct A;
let a = Arc::new(A) as Arc<dyn std::any::Any + Send + Sync>;
let a = Arc::new(A) as StateCell;
State::<A>::from_connect_parts(&new_socket(), &None, &a).unwrap();
}
}
34 changes: 10 additions & 24 deletions socketioxide/src/handler/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub(crate) trait ErasedMessageHandler<A: Adapter>: Send + Sync + 'static {
v: Value,
p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
);
}

Expand All @@ -114,7 +114,7 @@ pub trait MessageHandler<A: Adapter, T>: Send + Sync + 'static {
v: Value,
p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
);

#[doc(hidden)]
Expand Down Expand Up @@ -147,7 +147,7 @@ where
v: Value,
p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) {
self.handler.call(s, v, p, ack_id, state);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ pub trait FromMessageParts<A: Adapter>: Sized {
v: &mut Value,
p: &mut Vec<Vec<u8>>,
ack_id: &Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> Result<Self, Self::Error>;
}

Expand All @@ -214,7 +214,7 @@ pub trait FromMessage<A: Adapter, M = private::ViaRequest>: Sized {
v: Value,
p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> Result<Self, Self::Error>;
}

Expand All @@ -230,7 +230,7 @@ where
mut v: Value,
mut p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> Result<Self, Self::Error> {
Self::from_message_parts(&s, &mut v, &mut p, &ack_id, state)
}
Expand All @@ -243,14 +243,7 @@ where
Fut: Future<Output = ()> + Send + 'static,
A: Adapter,
{
fn call(
&self,
_: Arc<Socket<A>>,
_: Value,
_: Vec<Vec<u8>>,
_: Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
) {
fn call(&self, _: Arc<Socket<A>>, _: Value, _: Vec<Vec<u8>>, _: Option<i64>, _: &StateCell) {

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
let fut = (self.clone())();
tokio::spawn(fut);
}
Expand All @@ -262,14 +255,7 @@ where
F: FnOnce() + Send + Sync + Clone + 'static,
A: Adapter,
{
fn call(
&self,
_: Arc<Socket<A>>,
_: Value,
_: Vec<Vec<u8>>,
_: Option<i64>,
_: &Arc<dyn std::any::Any + Send + Sync>,
) {
fn call(&self, _: Arc<Socket<A>>, _: Value, _: Vec<Vec<u8>>, _: Option<i64>, _: &StateCell) {

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
(self.clone())();
}
}
Expand All @@ -293,7 +279,7 @@ macro_rules! impl_async_handler {
mut v: Value,
mut p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>)
state: &StateCell)

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
{
$(
let $ty = match $ty::from_message_parts(&s, &mut v, &mut p, &ack_id, state) {
Expand Down Expand Up @@ -338,7 +324,7 @@ macro_rules! impl_handler {
mut v: Value,
mut p: Vec<Vec<u8>>,
ack_id: Option<i64>,
state: &Arc<dyn std::any::Any + Send + Sync>)
state: &StateCell)

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
{
$(
let $ty = match $ty::from_message_parts(&s, &mut v, &mut p, &ack_id, state) {
Expand Down
2 changes: 1 addition & 1 deletion socketioxide/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct SocketIoBuilder<A: Adapter = LocalAdapter> {
config: SocketIoConfig,
engine_config_builder: EngineIoConfigBuilder,
adapter: std::marker::PhantomData<A>,
state: Arc<dyn std::any::Any + Send + Sync>,
state: StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
}

impl<A: Adapter> SocketIoBuilder<A> {
Expand Down
2 changes: 1 addition & 1 deletion socketioxide/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<A: Adapter> Clone for SocketIoLayer<A> {
impl<A: Adapter> SocketIoLayer<A> {
pub(crate) fn from_config(
config: Arc<SocketIoConfig>,
state: Arc<dyn std::any::Any + Send + Sync>,
state: StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> (Self, Arc<Client<A>>) {
let client = Arc::new(Client::new(config.clone(), state));
let layer = Self {
Expand Down
9 changes: 2 additions & 7 deletions socketioxide/src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<A: Adapter> Namespace<A> {
esocket: Arc<engineioxide::Socket<SocketData>>,
auth: Option<String>,
config: Arc<SocketIoConfig>,
state: &Arc<dyn std::any::Any + Send + Sync>,
state: &StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> Result<(), serde_json::Error> {
let socket: Arc<Socket<A>> = Socket::new(sid, self.clone(), esocket.clone(), config).into();

Expand Down Expand Up @@ -73,12 +73,7 @@ impl<A: Adapter> Namespace<A> {
self.sockets.read().unwrap().values().any(|s| s.id == sid)
}

pub fn recv(
&self,
sid: Sid,
packet: PacketData<'_>,
state: &Arc<dyn std::any::Any + Send + Sync>,
) -> Result<(), Error> {
pub fn recv(&self, sid: Sid, packet: PacketData<'_>, state: &StateCell) -> Result<(), Error> {

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
match packet {
PacketData::Connect(_) => unreachable!("connect packets should be handled before"),
PacketData::ConnectError => Err(Error::InvalidPacketType),
Expand Down
2 changes: 1 addition & 1 deletion socketioxide/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<A: Adapter, S: Clone> SocketIoService<S, A> {
pub(crate) fn with_config_inner(
inner: S,
config: Arc<SocketIoConfig>,
state: Arc<dyn std::any::Any + Send + Sync>,
state: StateCell,

Check failure

Code scanning / clippy

cannot find type StateCell in this scope Error

cannot find type StateCell in this scope
) -> (Self, Arc<Client<A>>) {
let engine_config = config.engine_config.clone();
let client = Arc::new(Client::new(config, state));
Expand Down
Loading

0 comments on commit 08077cd

Please sign in to comment.