naia_client_socket/
identity_receiver.rs

1use naia_socket_shared::IdentityToken;
2
3pub enum IdentityReceiverResult {
4    Waiting,
5    Success(IdentityToken),
6    ErrorResponseCode(u16),
7}
8
9/// Used to receive an IdentityToken from the Client Socket
10pub trait IdentityReceiver: IdentityReceiverClone + Send + Sync {
11    /// Receives an IdentityToken from the Client Socket
12    fn receive(&mut self) -> IdentityReceiverResult;
13}
14
15/// Used to clone Box<dyn IdentityReceiver>
16pub trait IdentityReceiverClone {
17    /// Clone the boxed IdentityReceiver
18    fn clone_box(&self) -> Box<dyn IdentityReceiver>;
19}
20
21impl<T: 'static + IdentityReceiver + Clone> IdentityReceiverClone for T {
22    fn clone_box(&self) -> Box<dyn IdentityReceiver> {
23        Box::new(self.clone())
24    }
25}
26
27impl Clone for Box<dyn IdentityReceiver> {
28    fn clone(&self) -> Box<dyn IdentityReceiver> {
29        IdentityReceiverClone::clone_box(self.as_ref())
30    }
31}