naia-client 0.24.0

Provides a cross-platform client that can send/receive messages to/from a server, and has a pool of in-scope entities/components that is synced with the server.
Documentation
use std::net::SocketAddr;

use naia_shared::{MutChannelType, MutReceiver};

pub struct MutChannelData {
    receiver: MutReceiver,
}

impl MutChannelData {
    pub fn new(diff_mask_length: u8) -> Self {
        Self {
            receiver: MutReceiver::new(diff_mask_length),
        }
    }
}

impl MutChannelType for MutChannelData {
    fn new_receiver(&mut self, address_opt: &Option<SocketAddr>) -> Option<MutReceiver> {
        if address_opt.is_some() {
            panic!(
                "should not initialize client MutReceiver with an address (there is only 1 server)"
            );
        }
        return Some(self.receiver.clone());
    }

    fn send(&self, diff: u8) {
        self.receiver.mutate(diff);
    }
}