Struct racetime::handler::RaceContext
source · [−]Expand description
A type passed to RaceHandler
callback methods which can be used to check the current status of the race or send messages.
Fields
sender: Arc<Mutex<WsSink>>
Implementations
sourceimpl RaceContext
impl RaceContext
sourcepub async fn data(&self) -> RwLockReadGuard<'_, RaceData>
pub async fn data(&self) -> RwLockReadGuard<'_, RaceData>
Returns the current state of the race.
sourcepub async fn send_raw(&self, message: &Json) -> Result<(), Error>
pub async fn send_raw(&self, message: &Json) -> Result<(), Error>
Sends a raw JSON message to the server.
The methods set_raceinfo
through remove_monitor
should be preferred.
sourcepub async fn send_message(&self, message: &str) -> Result<(), Error>
pub async fn send_message(&self, message: &str) -> Result<(), Error>
Send a chat message to the race room.
message
should be the message string you want to send.
sourcepub async fn set_raceinfo(
&self,
info: &str,
pos: RaceInfoPos
) -> Result<(), Error>
pub async fn set_raceinfo(
&self,
info: &str,
pos: RaceInfoPos
) -> Result<(), Error>
Set the info
field on the race room’s data.
info
should be the information you wish to set, and pos
the behavior in case there is existing info.
sourcepub async fn set_invitational(&self) -> Result<(), Error>
pub async fn set_invitational(&self) -> Result<(), Error>
Set the room in an invite-only state.
sourcepub async fn force_start(&self) -> Result<(), Error>
pub async fn force_start(&self) -> Result<(), Error>
Forces a start of the race.
sourcepub async fn cancel_race(&self) -> Result<(), Error>
pub async fn cancel_race(&self) -> Result<(), Error>
Forcibly cancels a race.
sourcepub async fn invite_user(&self, user: &str) -> Result<(), Error>
pub async fn invite_user(&self, user: &str) -> Result<(), Error>
Invites a user to the race.
user
should be the hashid of the user.
sourcepub async fn accept_request(&self, user: &str) -> Result<(), Error>
pub async fn accept_request(&self, user: &str) -> Result<(), Error>
Accepts a request to join the race room.
user
should be the hashid of the user.
sourcepub async fn force_unready(&self, user: &str) -> Result<(), Error>
pub async fn force_unready(&self, user: &str) -> Result<(), Error>
Forcibly unreadies an entrant.
user
should be the hashid of the user.
sourcepub async fn remove_entrant(&self, user: &str) -> Result<(), Error>
pub async fn remove_entrant(&self, user: &str) -> Result<(), Error>
Forcibly removes an entrant from the race.
user
should be the hashid of the user.
Trait Implementations
sourceimpl Clone for RaceContext
impl Clone for RaceContext
sourcefn clone(&self) -> RaceContext
fn clone(&self) -> RaceContext
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for RaceContext
impl Send for RaceContext
impl Sync for RaceContext
impl Unpin for RaceContext
impl !UnwindSafe for RaceContext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more