[−][src]Struct datetime_string::rfc3339::PartialTimeString
Owned string for a time in RFC 3339 partial-time
format, such as 12:34:56.7890
.
Available when alloc
feature is enabled.
This is "partial", because it is not associated to a time offset.
To create a value of this type, use str::parse
method or
std::convert::TryFrom
trait, or convert from &PartialTimeStr
.
Examples
use datetime_string::rfc3339::PartialTimeStr; use std::convert::TryFrom; let try_from = PartialTimeString::try_from("12:34:56.7890")?; let parse = "12:34:56.7890".parse::<PartialTimeString>()?; let parse2: PartialTimeString = "12:34:56.7890".parse()?; let to_owned = PartialTimeStr::from_str("12:34:56.7890")?.to_owned(); let into: PartialTimeString = PartialTimeStr::from_str("12:34:56.7890")?.into();
Implementations
impl PartialTimeString
[src]
#[must_use]pub fn as_deref(&self) -> &PartialTimeStr
[src]
Returns a &PartialTimeStr
for the string.
Examples
use datetime_string::rfc3339::PartialTimeStr; let time = "12:34:56.7890".parse::<PartialTimeString>()?; // Usually you don't need to call `as_deref()` explicitly, because // `Deref<Target = PartialTimeStr>` trait is implemented. let _: &PartialTimeStr = time.as_deref();
#[must_use]pub fn as_deref_mut(&mut self) -> &mut PartialTimeStr
[src]
Returns a &mut PartialTimeStr
for the string.
Examples
use datetime_string::rfc3339::PartialTimeStr; let mut time = "12:34:56.7890".parse::<PartialTimeString>()?; // Usually you don't need to call `as_deref_mut()` explicitly, because // `DerefMut` trait is implemented. let _: &mut PartialTimeStr = time.as_deref_mut();
Methods from Deref<Target = PartialTimeStr>
#[must_use]pub fn as_str(&self) -> &str
[src]
Returns a string slice.
Examples
let time = PartialTimeStr::from_str("12:34:56.7890")?; assert_eq!(time.as_str(), "12:34:56.7890");
#[must_use]pub fn as_bytes(&self) -> &[u8]
[src]
Returns a byte slice.
If you want to use indexed access, prefer as_bytes_fixed_len
.
Examples
let time = PartialTimeStr::from_str("12:34:56.7890")?; assert_eq!(time.as_str(), "12:34:56.7890");
#[must_use]pub fn hms(&self) -> &Hms6ColonStr
[src]
Returns a hh:mm:ss
substring.
Examples
let time = PartialTimeStr::from_str("12:34:56.7890")?; assert_eq!(time.hms(), "12:34:56");
#[must_use]pub fn hms_mut(&mut self) -> &mut Hms6ColonStr
[src]
Returns a mutable hh:mm:ss
substring.
Examples
let mut buf = "12:34:56.7890".to_owned(); let time = PartialTimeStr::from_mut_str(&mut buf)?; assert_eq!(time.as_str(), "12:34:56.7890"); time.hms_mut().set_time(23, 12, 1); assert_eq!(time.as_str(), "23:12:01.7890");
#[must_use]pub fn secfrac(&self) -> Option<&SecfracStr>
[src]
Returns time-secfrac
substring.
Examples
let time = PartialTimeStr::from_str("12:34:56.7890")?; assert_eq!(time.secfrac().unwrap(), ".7890");
#[must_use]pub fn secfrac_mut(&mut self) -> Option<&mut SecfracStr>
[src]
Returns a mutable time-secfrac
substring.
Examples
let mut buf = "12:34:56.7890".to_owned(); let time = PartialTimeStr::from_mut_str(&mut buf)?; assert_eq!(time.as_str(), "12:34:56.7890"); time.hms_mut().set_time(23, 12, 1); assert_eq!(time.as_str(), "23:12:01.7890");
pub fn to_chrono_naive_time(&self) -> NaiveTime
[src]
Converts the time to chrono::NaiveTime
.
Note that this truncates subnanosecond secfrac.
Enabled by chrono04
feature.
Examples
use chrono04::NaiveTime; let time = PartialTimeStr::from_str("12:34:56.01234567899999")?; assert_eq!(time.to_chrono_naive_time(), NaiveTime::from_hms_nano(12, 34, 56, 12_345_678)); let leap = PartialTimeStr::from_str("23:59:60.876543210999")?; assert_eq!(leap.to_chrono_naive_time(), NaiveTime::from_hms_nano(23, 59, 59, 1_876_543_210));
Trait Implementations
impl AsMut<PartialTimeStr> for PartialTimeString
[src]
fn as_mut(&mut self) -> &mut PartialTimeStr
[src]
impl AsRef<[u8]> for PartialTimeString
[src]
impl AsRef<PartialTimeStr> for PartialTimeString
[src]
fn as_ref(&self) -> &PartialTimeStr
[src]
impl AsRef<str> for PartialTimeString
[src]
impl Borrow<PartialTimeStr> for PartialTimeString
[src]
fn borrow(&self) -> &PartialTimeStr
[src]
impl BorrowMut<PartialTimeStr> for PartialTimeString
[src]
fn borrow_mut(&mut self) -> &mut PartialTimeStr
[src]
impl Clone for PartialTimeString
[src]
fn clone(&self) -> PartialTimeString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PartialTimeString
[src]
impl Deref for PartialTimeString
[src]
type Target = PartialTimeStr
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for PartialTimeString
[src]
impl<'de> Deserialize<'de> for PartialTimeString
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for PartialTimeString
[src]
impl Eq for PartialTimeString
[src]
impl<'_> From<&'_ PartialTimeStr> for PartialTimeString
[src]
fn from(v: &PartialTimeStr) -> Self
[src]
impl From<PartialTimeString> for Vec<u8>
[src]
fn from(v: PartialTimeString) -> Vec<u8>
[src]
impl From<PartialTimeString> for String
[src]
fn from(v: PartialTimeString) -> String
[src]
impl FromStr for PartialTimeString
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for PartialTimeString
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for PartialTimeString
[src]
fn cmp(&self, other: &PartialTimeString) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'_> PartialEq<&'_ [u8]> for PartialTimeString
[src]
impl<'_> PartialEq<&'_ PartialTimeStr> for PartialTimeString
[src]
fn eq(&self, o: &&PartialTimeStr) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ PartialTimeString> for PartialTimeString
[src]
fn eq(&self, o: &&PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ PartialTimeString> for str
[src]
fn eq(&self, o: &&PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ PartialTimeString> for [u8]
[src]
fn eq(&self, o: &&PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ str> for PartialTimeString
[src]
impl PartialEq<[u8]> for PartialTimeString
[src]
impl<'_> PartialEq<[u8]> for &'_ PartialTimeString
[src]
impl PartialEq<PartialTimeStr> for PartialTimeString
[src]
impl PartialEq<PartialTimeString> for PartialTimeString
[src]
fn eq(&self, other: &PartialTimeString) -> bool
[src]
fn ne(&self, other: &PartialTimeString) -> bool
[src]
impl<'_> PartialEq<PartialTimeString> for &'_ PartialTimeString
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<PartialTimeString> for PartialTimeStr
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<PartialTimeString> for &'_ PartialTimeStr
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<PartialTimeString> for str
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<PartialTimeString> for &'_ str
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<PartialTimeString> for [u8]
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<PartialTimeString> for &'_ [u8]
[src]
fn eq(&self, o: &PartialTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<str> for PartialTimeString
[src]
impl<'_> PartialEq<str> for &'_ PartialTimeString
[src]
impl<'_> PartialOrd<&'_ [u8]> for PartialTimeString
[src]
fn partial_cmp(&self, o: &&[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ PartialTimeStr> for PartialTimeString
[src]
fn partial_cmp(&self, o: &&PartialTimeStr) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ PartialTimeString> for PartialTimeString
[src]
fn partial_cmp(&self, o: &&PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ PartialTimeString> for str
[src]
fn partial_cmp(&self, o: &&PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ PartialTimeString> for [u8]
[src]
fn partial_cmp(&self, o: &&PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ str> for PartialTimeString
[src]
fn partial_cmp(&self, o: &&str) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<[u8]> for PartialTimeString
[src]
fn partial_cmp(&self, o: &[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<[u8]> for &'_ PartialTimeString
[src]
fn partial_cmp(&self, o: &[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<PartialTimeStr> for PartialTimeString
[src]
fn partial_cmp(&self, o: &PartialTimeStr) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<PartialTimeString> for PartialTimeString
[src]
fn partial_cmp(&self, other: &PartialTimeString) -> Option<Ordering>
[src]
fn lt(&self, other: &PartialTimeString) -> bool
[src]
fn le(&self, other: &PartialTimeString) -> bool
[src]
fn gt(&self, other: &PartialTimeString) -> bool
[src]
fn ge(&self, other: &PartialTimeString) -> bool
[src]
impl<'_> PartialOrd<PartialTimeString> for &'_ PartialTimeString
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<PartialTimeString> for PartialTimeStr
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<PartialTimeString> for &'_ PartialTimeStr
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<PartialTimeString> for str
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<PartialTimeString> for &'_ str
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<PartialTimeString> for [u8]
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<PartialTimeString> for &'_ [u8]
[src]
fn partial_cmp(&self, o: &PartialTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<str> for PartialTimeString
[src]
fn partial_cmp(&self, o: &str) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<str> for &'_ PartialTimeString
[src]
fn partial_cmp(&self, o: &str) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for PartialTimeString
[src]
impl StructuralEq for PartialTimeString
[src]
impl StructuralPartialEq for PartialTimeString
[src]
impl<'_> TryFrom<&'_ [u8]> for PartialTimeString
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &[u8]) -> Result<Self, Self::Error>
[src]
impl<'_> TryFrom<&'_ str> for PartialTimeString
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &str) -> Result<Self, Self::Error>
[src]
impl TryFrom<String> for PartialTimeString
[src]
type Error = ConversionError<String>
The type returned in the event of a conversion error.
fn try_from(v: String) -> Result<Self, Self::Error>
[src]
impl TryFrom<Vec<u8>> for PartialTimeString
[src]
Auto Trait Implementations
impl RefUnwindSafe for PartialTimeString
impl Send for PartialTimeString
impl Sync for PartialTimeString
impl Unpin for PartialTimeString
impl UnwindSafe for PartialTimeString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,