Trait serenity::utils::Parse [−][src]
pub trait Parse: Sized { type Err; #[must_use] fn parse<'life0, 'life1, 'life2, 'async_trait>(
ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait; }
Expand description
Parse a value from a string in context of a received message.
This trait is a superset of std::str::FromStr
. The
difference is that this trait aims to support serenity-specific Discord types like Member
or Message
.
Trait implementations may do network requests as part of their parsing procedure.
Useful for implementing argument parsing in command frameworks.
Associated Types
Loading content...Required methods
#[must_use]fn parse<'life0, 'life1, 'life2, 'async_trait>(
ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
#[must_use]
fn parse<'life0, 'life1, 'life2, 'async_trait>(ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Expand description
Parses a string s
as a command parameter of this type.
Implementors
impl Parse for Message
[src]
impl Parse for Message
[src]Look up a message by a string.
The lookup strategy is as follows (in order):
- Lookup by “{channel ID}-{message ID}” (retrieved by shift-clicking on “Copy ID”)
- Lookup by message ID (the message must be in the context channel)
- Lookup by message URL
type Err = MessageParseError
fn parse<'life0, 'life1, 'life2, 'async_trait>(
ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
impl Parse for Member
[src]
impl Parse for Member
[src]Look up a guild member by a string case-insensitively.
Requires the cache feature to be enabled.
The lookup strategy is as follows (in order):
- Lookup by ID.
- Lookup by mention.
- Lookup by name#discrim
- Lookup by name
- Lookup by nickname
type Err = MemberParseError
fn parse<'life0, 'life1, 'life2, 'async_trait>(
ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
ctx: &'life0 Context,
msg: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
impl<T: FromStr> Parse for T
[src]
impl<T: FromStr> Parse for T
[src]type Err = <T as FromStr>::Err
fn parse<'life0, 'life1, 'life2, 'async_trait>(
__arg0: &'life0 Context,
__arg1: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
__arg0: &'life0 Context,
__arg1: &'life1 Message,
s: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,