Struct Typing

Source
pub struct Typing(/* private fields */);
Expand description

A struct to start typing in a Channel for an indefinite period of time.

It indicates that the current user is currently typing in the channel.

Typing is started by using the Typing::start method and stopped by using the Typing::stop method. Note that on some clients, typing may persist for a few seconds after Typing::stop is called. Typing is also stopped when the struct is dropped.

If a message is sent while typing is triggered, the user will stop typing for a brief period of time and then resume again until either Typing::stop is called or the struct is dropped.

This should rarely be used for bots, although it is a good indicator that a long-running command is still being processed.

§Examples

let channel_id = ChannelId::new(7);
// Initiate typing (assuming `http` is bound)
let typing = Typing::start(Arc::new(http), channel_id);

// Run some long-running process
long_process();

// Stop typing
typing.stop();

Implementations§

Source§

impl Typing

Source

pub fn start(http: Arc<Http>, channel_id: ChannelId) -> Self

Starts typing in the specified Channel for an indefinite period of time.

Returns Typing. To stop typing, you must call the Typing::stop method on the returned Typing object or wait for it to be dropped. Note that on some clients, typing may persist for a few seconds after stopped.

§Errors

Returns an Error::Http if there is an error.

Source

pub fn stop(self) -> bool

Stops typing in Channel.

This should be used to stop typing after it is started using Typing::start. Typing may persist for a few seconds on some clients after this is called. Returns false if typing has already stopped.

Trait Implementations§

Source§

impl Debug for Typing

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Typing

§

impl !RefUnwindSafe for Typing

§

impl Send for Typing

§

impl Sync for Typing

§

impl Unpin for Typing

§

impl !UnwindSafe for Typing

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T