pub struct DateTimeType {
pub formats: Vec<String>,
}Expand description
A datetime parameter type that parses ISO 8601 format strings.
By default, attempts to parse using these formats (in order):
%Y-%m-%d(date only)%Y-%m-%dT%H:%M:%S(datetime with T separator)%Y-%m-%d %H:%M:%S(datetime with space separator)
Custom formats can be specified using the formats field.
Fields§
§formats: Vec<String>The datetime formats to try, in order.
Implementations§
Source§impl DateTimeType
impl DateTimeType
Sourcepub const DEFAULT_FORMATS: &'static [&'static str]
pub const DEFAULT_FORMATS: &'static [&'static str]
Default datetime formats.
Sourcepub fn with_formats(
formats: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_formats( formats: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Create a datetime type with custom formats.
Trait Implementations§
Source§impl Clone for DateTimeType
impl Clone for DateTimeType
Source§fn clone(&self) -> DateTimeType
fn clone(&self) -> DateTimeType
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DateTimeType
impl Debug for DateTimeType
Source§impl Default for DateTimeType
impl Default for DateTimeType
Source§impl TypeConverter for DateTimeType
impl TypeConverter for DateTimeType
Source§type Value = NaiveDateTime
type Value = NaiveDateTime
The Rust type that this parameter type converts to.
Source§fn convert(&self, value: &str) -> Result<Self::Value, String>
fn convert(&self, value: &str) -> Result<Self::Value, String>
Convert a string value to the target type. Read more
Source§fn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type (used in help text). Read more
Source§fn get_missing_message(&self) -> Option<String>
fn get_missing_message(&self) -> Option<String>
Returns an optional message when a required value is missing.
Source§fn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values. Read more
Source§fn shell_complete(&self, _incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, _incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value. Read more
Source§fn is_composite(&self) -> bool
fn is_composite(&self) -> bool
Whether this type is a composite type (like Tuple).
Auto Trait Implementations§
impl Freeze for DateTimeType
impl RefUnwindSafe for DateTimeType
impl Send for DateTimeType
impl Sync for DateTimeType
impl Unpin for DateTimeType
impl UnsafeUnpin for DateTimeType
impl UnwindSafe for DateTimeType
Blanket Implementations§
Source§impl<T> AnyTypeConverter for T
impl<T> AnyTypeConverter for T
Source§fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>
fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>
Convert a string value to the target type, returning as Box.
Source§fn convert_multi(
&self,
values: &[String],
) -> Result<Box<dyn Any + Sync + Send>, String>
fn convert_multi( &self, values: &[String], ) -> Result<Box<dyn Any + Sync + Send>, String>
Convert multiple string values to the target type, returning as Box. Read more
Source§fn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type.
Source§fn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values.
Source§fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value.
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