Skip to main content

Server

Struct Server 

Source
pub struct Server { /* private fields */ }
Expand description

The build’s end of the link, for one client: it turns the client’s lines into answers over the App the backend runs, and gives the backend a play’s input frame by frame. The backend makes one per connection.

Each frame the backend calls handle for each line read and sends the answers; input before App::frame, adding what it gives after the devices’ input; then after_frame, sending what it gives; if wants_screenshot, reads the window and sends screenshot’s line; and if wants_snapshot, takes a heap snapshot and sends snapshot’s.

Implementations§

Source§

impl Server

Source

pub fn new(token: String, game: String) -> Self

The server of a build whose token is token, of the game game (the window’s title).

Source

pub fn handle<G: GameData>(&mut self, line: &str, app: &App<G>) -> Handled

What line (without its line break) asks of app.

Source

pub fn input<G: GameData>(&mut self, app: &App<G>, out: &mut Vec<RawInputEvent>)

This frame’s input from the play being played, if one is: the next frame of its steps, put in out after what is there. While the game loads or is suspended the steps wait. A play whose game failed to load, or one of whose actions can’t be pressed, ends with an error, having played nothing more.

Source

pub fn after_frame<G: GameData>(&mut self, app: &App<G>) -> Vec<String>

The answers due now that app’s frame has run: a play’s whose last frame it was, then those of the requests that waited behind it, up to the next play or picture.

Source

pub fn wants_screenshot(&self) -> bool

Whether the backend should read the window after this frame and answer with screenshot.

Source

pub fn screenshot(&mut self, png: &[u8], width: u32, height: u32) -> String

The answer to a Request::Screenshot: png, the window’s picture of width × height pixels. Requests behind it are answered from the next after_frame.

Source

pub fn wants_snapshot(&self) -> bool

Whether the backend should take a heap snapshot after this frame and answer with snapshot.

Source

pub fn snapshot<G: GameData>( &mut self, app: &App<G>, snapshot: Option<HeapSnapshot>, ) -> String

The answer to a Request::Perf that asked for a snapshot: app’s records it asked for, and snapshot, the backend’s (App::heap_snapshot; None where it takes none). Requests behind it are answered from the next after_frame.

Trait Implementations§

Source§

impl Debug for Server

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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.