pub enum PartialOption<T: BasicOption> {
Value(T),
Partial(T::Partial, Error),
None,
}
Expand description
A field which may be partially parsed.
This is used for fields which may not be fully parseable, such as when handling autocomplete interactions.
Variants§
Value(T)
A successfully parsed value.
Partial(T::Partial, Error)
A partially parsed value, along with the error that occurred while attempting to parse it.
None
A value that has not been entered yet.
Implementations§
Source§impl<T: BasicOption> PartialOption<T>
impl<T: BasicOption> PartialOption<T>
Sourcepub fn into_value(self) -> Option<T>
pub fn into_value(self) -> Option<T>
Extract the parsed value from this field.
Sourcepub fn into_partial(self) -> Option<(T::Partial, Error)>
pub fn into_partial(self) -> Option<(T::Partial, Error)>
Extract the partially parsed value and the error that occurred while attempting to parse it from this field.
Sourcepub const fn as_value(&self) -> Option<&T>
pub const fn as_value(&self) -> Option<&T>
Get a reference to the parsed value from this field.
Sourcepub const fn as_partial(&self) -> Option<(&T::Partial, &Error)>
pub const fn as_partial(&self) -> Option<(&T::Partial, &Error)>
Get a reference to the partially parsed value and the error that occurred while attempting to parse it from this field.
Sourcepub const fn is_partial(&self) -> bool
pub const fn is_partial(&self) -> bool
Check if this field is a partially parsed value.
Source§impl<T: BasicOption<Partial = T>> PartialOption<T>
impl<T: BasicOption<Partial = T>> PartialOption<T>
Source§impl<T: BasicOption> PartialOption<Option<T>>
impl<T: BasicOption> PartialOption<Option<T>>
Sourcepub fn flatten(self) -> PartialOption<T>
pub fn flatten(self) -> PartialOption<T>
Flatten this field into a PartialOption<T>
.
Trait Implementations§
Source§impl<T: BasicOption> BasicOption for PartialOption<T>
impl<T: BasicOption> BasicOption for PartialOption<T>
Source§type Partial = <<T as BasicOption>::Partial as BasicOption>::Partial
type Partial = <<T as BasicOption>::Partial as BasicOption>::Partial
The type of this option when it may not be fully parseable. Read more
Source§fn create_option(
name: impl Into<String>,
description: impl Into<String>,
) -> CreateCommandOption
fn create_option( name: impl Into<String>, description: impl Into<String>, ) -> CreateCommandOption
Create the command option.
Source§fn from_value(value: Option<&CommandDataOptionValue>) -> Result<Self>
fn from_value(value: Option<&CommandDataOptionValue>) -> Result<Self>
Extract data from a
CommandDataOptionValue
. Read moreAuto Trait Implementations§
impl<T> Freeze for PartialOption<T>
impl<T> !RefUnwindSafe for PartialOption<T>
impl<T> Send for PartialOption<T>
impl<T> Sync for PartialOption<T>
impl<T> Unpin for PartialOption<T>
impl<T> !UnwindSafe for PartialOption<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more