Skip to main content

Relay

Struct Relay 

Source
pub struct Relay {
    pub max_rooms: usize,
    /* private fields */
}
Expand description

The rooms and the games connected to a relay.

Fields§

§max_rooms: usize

The most rooms open at once; a host beyond it is refused.

Implementations§

Source§

impl Relay

Source

pub fn new(seed: u64) -> Relay

An empty relay; seed starts its room codes.

Source

pub fn with_store(self, store: Box<dyn Store>) -> Relay

Keeps the rooms’ towns in store.

Source

pub fn room_count(&self) -> usize

How many rooms are open.

Source

pub fn game_count(&self) -> usize

How many games are connected.

Source

pub fn room_of(&self, client: Client) -> Option<(String, u8)>

The room and player number of a connected game, if it is in a room.

Source

pub fn host_hello(&self, room: &str) -> Option<&Hello>

The Hello of a room’s host.

Source

pub fn members(&self, room: &str) -> Vec<Client> ⓘ

The games in a room.

Source

pub fn watch(&mut self, room: &str)

The server runs this room’s game: its digests are the reference from now on.

Source

pub fn server_digest( &mut self, room: &str, epoch: u32, update: u64, crc: u32, ) -> Vec<(Client, FromRelay)>

The server’s own digest of a room’s game (see Relay::watch): the messages the check gives.

Source

pub fn take_server_saves(&mut self) -> Vec<String>

The rooms whose server-run game is to be kept since the last call: the server sends each its save.

Source

pub fn connect(&mut self, client: Client)

A game connected.

Source

pub fn handle(&mut self, client: Client, request: ToRelay) -> Reply

A game’s request.

Source

pub fn disconnect(&mut self, client: Client) -> Vec<(Client, FromRelay)>

A game’s connection closed: it leaves its room.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Relay

§

impl !Sync for Relay

§

impl !UnwindSafe for Relay

§

impl Freeze for Relay

§

impl Send for Relay

§

impl Unpin for Relay

§

impl UnsafeUnpin for Relay

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.