Struct tomllib::types::TimeOffsetAmount
[−]
[src]
pub struct TimeOffsetAmount<'a> { pub pos_neg: PosNeg, pub hour: Cow<'a, str>, pub minute: Cow<'a, str>, }
A positive or negative amount of hours and minutes offset from UTC.
Fields
pos_neg: PosNeg
Represents whether the offset is positive or negative.
hour: Cow<'a, str>
Represents the number of hours that time is offset from UTC.Must be 2 decimal digits between 0 23 inclusive.
minute: Cow<'a, str>
Represents the number of minutes that time is offset from UTC. Must be 2 decimal digits between 0 59 inclusive.
Methods
impl<'a> TimeOffsetAmount<'a>
[src]
fn new_str(pos_neg: &'a str, hour: &'a str, minute: &'a str) -> TimeOffsetAmount<'a>
impl<'a> TimeOffsetAmount<'a>
[src]
fn from_str<S>(pos_neg: S, hour: S, minute: S) -> Result<TimeOffsetAmount<'a>, TOMLError> where S: Into<String>
Create a new TimeOffsetAmount
from string type values. Returns Ok()
on success and Err()
on failure.
Examples
use tomllib::types::TimeOffsetAmount; let offset = TimeOffsetAmount::from_str("-", "04", "00").unwrap();
fn validate(&self) -> bool
Validates a created TimeOffsetAmount
.
Examples
use tomllib::types::{TimeOffsetAmount, PosNeg}; let offset_wrong = TimeOffsetAmount{pos_neg: PosNeg::Pos, hour: "31".into(), minute: "30".into()}; let offset_right = TimeOffsetAmount{pos_neg: PosNeg::Pos, hour: "07".into(), minute: "00".into()}; assert!(!offset_wrong.validate()); assert!(offset_right.validate());
Trait Implementations
impl<'a> Clone for TimeOffsetAmount<'a>
[src]
fn clone(&self) -> TimeOffsetAmount<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> Eq for TimeOffsetAmount<'a>
[src]
impl<'a> Debug for TimeOffsetAmount<'a>
[src]
impl<'a> PartialEq for TimeOffsetAmount<'a>
[src]
fn eq(&self, other: &TimeOffsetAmount<'a>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.