Skip to main content

CsaCommand

Enum CsaCommand 

Source
#[non_exhaustive]
pub enum CsaCommand {
Show 18 variants Login { name: String, password: String, x1: bool, }, Logout, Agree { game_id: Option<String>, }, Reject { game_id: Option<String>, }, Challenge, Meta(MetaCommand), LoginOk { name: String, }, LoginIncorrect, LogoutCompleted, ChallengeAccepted, BeginGameSummary, Start { game_id: String, }, RejectNotice { game_id: String, by: String, }, End(EndMarker), Info(InfoLine), Move(MoveLine), Special { kind: SpecialMove, elapsed: Option<u64>, }, KeepAlive,
}
Expand description

One line of the CSA server protocol.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Login

LOGIN <name> <password> with an optional x1 suffix.

Fields

§name: String

The account name.

§password: String

The password field, which in CSA mode also carries the game name.

§x1: bool

Whether the x1 extension was requested.

§

Logout

LOGOUT

§

Agree

AGREE or AGREE <game_id>.

Fields

§game_id: Option<String>

The game id echoed back to the server.

§

Reject

REJECT or REJECT <game_id>, sent by the client.

Fields

§game_id: Option<String>

The game id echoed back to the server.

§

Challenge

CHALLENGE, a legacy no-op the server answers with CHALLENGE ACCEPTED.

§

Meta(MetaCommand)

A %% administrative command.

§

LoginOk

LOGIN:<name> OK

Fields

§name: String

The account name the server accepted.

§

LoginIncorrect

LOGIN:incorrect

§

LogoutCompleted

LOGOUT:completed

§

ChallengeAccepted

CHALLENGE ACCEPTED

§

BeginGameSummary

BEGIN Game_Summary, the first line of a game proposal.

Feed this line and everything after it to crate::GameSummaryReader.

§

Start

START:<game_id>

Fields

§game_id: String

The game id that is now in progress.

§

RejectNotice

REJECT:<game_id> by <name>, sent by the server to both players.

Fields

§game_id: String

The rejected game id.

§by: String

Who rejected it, or the Server (timed out).

§

End(EndMarker)

A #-prefixed terminal marker.

§

Info(InfoLine)

A ##[TAG] ... informational line.

§

Move(MoveLine)

A move, optionally annotated with elapsed time and a comment.

§

Special

A %-prefixed special move, optionally annotated with elapsed time.

Fields

§kind: SpecialMove

Which special move.

§elapsed: Option<u64>

Raw integer time annotation, with the same unit contract as MoveLine::elapsed.

§

KeepAlive

An empty line, used as an application-level keepalive.

The CSA rule is that a client must not send these more often than once every 30 seconds.

Implementations§

Source§

impl CsaCommand

Source

pub const fn direction(&self) -> Option<CsaCommandDirection>

Which way this command travels, or None when the direction is unknown.

Source

pub const fn is_client_to_server(&self) -> bool

Whether a client may send this command.

Source

pub const fn is_server_to_client(&self) -> bool

Whether a server may send this command.

Trait Implementations§

Source§

impl Clone for CsaCommand

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CsaCommand

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CsaCommand

Source§

impl PartialEq for CsaCommand

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CsaCommand

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.