[][src]Struct datetime_string::rfc3339::FullTimeStr

#[repr(transparent)]pub struct FullTimeStr(_);

String slice for a time in RFC 3339 full-time format, such as 12:34:56.7890-23:12.

Implementations

impl FullTimeStr[src]

pub fn from_str(s: &str) -> Result<&Self, Error>[src]

Creates a new &FullTimeStr from a string slice.

Examples

let time = FullTimeStr::from_str("12:34:56.7890-23:12")?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

assert!(FullTimeStr::from_str("12:34:56Z").is_ok());
assert!(FullTimeStr::from_str("23:59:59+23:59").is_ok());
assert!(FullTimeStr::from_str("00:00:00.0-00:00").is_ok());

pub fn from_mut_str(s: &mut str) -> Result<&mut Self, Error>[src]

Creates a new &mut FullTimeStr from a mutable string slice.

Examples

let mut buf = "12:34:56.7890-23:12".to_owned();
let time = FullTimeStr::from_mut_str(&mut buf)?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

time.partial_time_mut().hms_mut().set_time(0, 22, 44)?;
assert_eq!(time.as_str(), "00:22:44.7890-23:12");

pub fn from_bytes(s: &[u8]) -> Result<&Self, Error>[src]

Creates a new &FullTimeStr from a byte slice.

Examples

let time = FullTimeStr::from_bytes(b"12:34:56.7890-23:12")?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

assert!(FullTimeStr::from_bytes(b"12:34:56Z").is_ok());
assert!(FullTimeStr::from_bytes(b"23:59:59+23:59").is_ok());
assert!(FullTimeStr::from_bytes(b"00:00:00.0-00:00").is_ok());

pub fn from_bytes_mut(s: &mut [u8]) -> Result<&mut Self, Error>[src]

Creates a new &mut FullTimeStr from a mutable byte slice.

Examples

let mut buf = b"12:34:56.7890-23:12".to_owned();
let time = FullTimeStr::from_bytes_mut(&mut buf[..])?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

time.partial_time_mut().hms_mut().set_time(0, 22, 44)?;
assert_eq!(time.as_str(), "00:22:44.7890-23:12");

#[must_use]pub fn as_str(&self) -> &str[src]

Returns a string slice.

Examples

let time = FullTimeStr::from_str("12:34:56.7890-23:12")?;

assert_eq!(time.as_str(), "12:34:56.7890-23:12");

#[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 = FullTimeStr::from_str("12:34:56.7890-23:12")?;

assert_eq!(time.as_bytes(), b"12:34:56.7890-23:12");

#[must_use]pub fn decompose(&self) -> (&PartialTimeStr, &TimeOffsetStr)[src]

Decomposes the string into &PartialTimeStr and &TimeOffsetStr.

Examples

let time = FullTimeStr::from_str("12:34:56.7890-23:12")?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

let (partial_time, offset) = time.decompose();
assert_eq!(partial_time.as_str(), "12:34:56.7890");
assert_eq!(offset.as_str(), "-23:12");

#[must_use]pub fn decompose_mut(&mut self) -> (&mut PartialTimeStr, &mut TimeOffsetStr)[src]

Decomposes the string into &mut PartialTimeStr and &mut TimeOffsetStr.

Examples

use datetime_string::common::TimeOffsetSign;

let mut buf = "12:34:56.7890-23:12".to_owned();
let time = FullTimeStr::from_mut_str(&mut buf)?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

let (partial_time, offset) = time.decompose_mut();
assert_eq!(partial_time.as_str(), "12:34:56.7890");
assert_eq!(offset.as_str(), "-23:12");

partial_time.secfrac_mut().unwrap().digits_mut().fill_with_zero();
offset.to_numoffset_mut().unwrap().set_sign(TimeOffsetSign::Positive);
assert_eq!(time.as_str(), "12:34:56.0000+23:12");

#[must_use]pub fn partial_time(&self) -> &PartialTimeStr[src]

Returns a &PartialTimeStr.

Examples

let time = FullTimeStr::from_str("12:34:56.7890-23:12")?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

let partial_time = time.partial_time();
assert_eq!(partial_time.as_str(), "12:34:56.7890");

#[must_use]pub fn partial_time_mut(&mut self) -> &mut PartialTimeStr[src]

Returns a &mut PartialTimeStr.

Examples

use datetime_string::common::TimeOffsetSign;

let mut buf = "12:34:56.7890-23:12".to_owned();
let time = FullTimeStr::from_mut_str(&mut buf)?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

let partial_time = time.partial_time_mut();
assert_eq!(partial_time.as_str(), "12:34:56.7890");

partial_time.secfrac_mut().unwrap().digits_mut().fill_with_zero();
assert_eq!(time.as_str(), "12:34:56.0000-23:12");

#[must_use]pub fn offset(&self) -> &TimeOffsetStr[src]

Returns a &TimeOffsetStr.

Examples

let time = FullTimeStr::from_str("12:34:56.7890-23:12")?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

let offset = time.offset();
assert_eq!(offset.as_str(), "-23:12");

#[must_use]pub fn offset_mut(&mut self) -> &mut TimeOffsetStr[src]

Returns a &mut PartialTimeStr.

Examples

use datetime_string::common::TimeOffsetSign;

let mut buf = "12:34:56.7890-23:12".to_owned();
let time = FullTimeStr::from_mut_str(&mut buf)?;
assert_eq!(time.as_str(), "12:34:56.7890-23:12");

let offset = time.offset_mut();
assert_eq!(offset.as_str(), "-23:12");

offset.to_numoffset_mut().unwrap().set_sign(TimeOffsetSign::Positive);
assert_eq!(time.as_str(), "12:34:56.7890+23:12");

Trait Implementations

impl AsMut<FullTimeStr> for FullTimeString[src]

impl AsMut<FullTimeStr> for FullTimeStr[src]

impl AsRef<[u8]> for FullTimeStr[src]

impl AsRef<FullTimeStr> for FullTimeString[src]

impl AsRef<FullTimeStr> for FullTimeStr[src]

impl AsRef<str> for FullTimeStr[src]

impl Borrow<FullTimeStr> for FullTimeString[src]

impl BorrowMut<FullTimeStr> for FullTimeString[src]

impl Debug for FullTimeStr[src]

impl Deref for FullTimeStr[src]

type Target = str

The resulting type after dereferencing.

impl<'de> Deserialize<'de> for &'de FullTimeStr[src]

impl Display for FullTimeStr[src]

impl Eq for FullTimeStr[src]

impl<'_> From<&'_ FullTimeStr> for FullTimeString[src]

impl<'a> From<&'a FullTimeStr> for &'a str[src]

impl Hash for FullTimeStr[src]

impl Ord for FullTimeStr[src]

impl<'_> PartialEq<&'_ [u8]> for FullTimeStr[src]

impl<'_> PartialEq<&'_ FullTimeStr> for FullTimeString[src]

impl<'_> PartialEq<&'_ FullTimeStr> for FullTimeStr[src]

impl<'_> PartialEq<&'_ FullTimeStr> for [u8][src]

impl<'_> PartialEq<&'_ FullTimeStr> for str[src]

impl<'_> PartialEq<&'_ str> for FullTimeStr[src]

impl PartialEq<[u8]> for FullTimeStr[src]

impl<'_> PartialEq<[u8]> for &'_ FullTimeStr[src]

impl PartialEq<FullTimeStr> for FullTimeString[src]

impl PartialEq<FullTimeStr> for FullTimeStr[src]

impl<'_> PartialEq<FullTimeStr> for &'_ FullTimeStr[src]

impl PartialEq<FullTimeStr> for [u8][src]

impl<'_> PartialEq<FullTimeStr> for &'_ [u8][src]

impl PartialEq<FullTimeStr> for str[src]

impl<'_> PartialEq<FullTimeStr> for &'_ str[src]

impl PartialEq<FullTimeString> for FullTimeStr[src]

impl<'_> PartialEq<FullTimeString> for &'_ FullTimeStr[src]

impl PartialEq<str> for FullTimeStr[src]

impl<'_> PartialEq<str> for &'_ FullTimeStr[src]

impl<'_> PartialOrd<&'_ [u8]> for FullTimeStr[src]

impl<'_> PartialOrd<&'_ FullTimeStr> for FullTimeString[src]

impl<'_> PartialOrd<&'_ FullTimeStr> for FullTimeStr[src]

impl<'_> PartialOrd<&'_ FullTimeStr> for [u8][src]

impl<'_> PartialOrd<&'_ FullTimeStr> for str[src]

impl<'_> PartialOrd<&'_ str> for FullTimeStr[src]

impl PartialOrd<[u8]> for FullTimeStr[src]

impl<'_> PartialOrd<[u8]> for &'_ FullTimeStr[src]

impl PartialOrd<FullTimeStr> for FullTimeString[src]

impl PartialOrd<FullTimeStr> for FullTimeStr[src]

impl<'_> PartialOrd<FullTimeStr> for &'_ FullTimeStr[src]

impl PartialOrd<FullTimeStr> for [u8][src]

impl<'_> PartialOrd<FullTimeStr> for &'_ [u8][src]

impl PartialOrd<FullTimeStr> for str[src]

impl<'_> PartialOrd<FullTimeStr> for &'_ str[src]

impl PartialOrd<FullTimeString> for FullTimeStr[src]

impl<'_> PartialOrd<FullTimeString> for &'_ FullTimeStr[src]

impl PartialOrd<str> for FullTimeStr[src]

impl<'_> PartialOrd<str> for &'_ FullTimeStr[src]

impl Serialize for FullTimeStr[src]

impl StructuralEq for FullTimeStr[src]

impl StructuralPartialEq for FullTimeStr[src]

impl ToOwned for FullTimeStr[src]

type Owned = FullTimeString

The resulting type after obtaining ownership.

impl<'a> TryFrom<&'a [u8]> for &'a FullTimeStr[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a mut [u8]> for &'a mut FullTimeStr[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a mut str> for &'a mut FullTimeStr[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a str> for &'a FullTimeStr[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]