pub struct Interval {
pub months: i32,
pub days: i32,
pub microseconds: i64,
}
Fields§
§months: i32
§days: i32
§microseconds: i64
Implementations§
Source§impl Interval
impl Interval
Sourcepub fn from_duration(duration: Duration) -> Option<Interval>
pub fn from_duration(duration: Duration) -> Option<Interval>
Tries to convert from the Duration
type to a Interval
. Will
return None
on a overflow. This is a lossy conversion in that
any units smaller than a microsecond will be lost.
Source§impl Interval
impl Interval
pub fn from_postgres(iso_str: &str) -> Result<Interval, ParseError>
Source§impl Interval
impl Interval
Sourcepub fn new(months: i32, days: i32, microseconds: i64) -> Interval
pub fn new(months: i32, days: i32, microseconds: i64) -> Interval
Create a new instance of interval from the months, days, and microseconds.
Sourcepub fn to_iso_8601(&self) -> String
pub fn to_iso_8601(&self) -> String
Output the interval as iso 8601 compliant string.
Sourcepub fn to_postgres(&self) -> String
pub fn to_postgres(&self) -> String
Output the interval as a postgres interval string.
Source§impl Interval
impl Interval
Sourcepub fn checked_add(self, other_interval: Interval) -> Option<Interval>
pub fn checked_add(self, other_interval: Interval) -> Option<Interval>
Checked interval addition. Computes Interval + Interval
and None
if there
was an overflow.
Sourcepub fn add_day_time(
self,
days: i32,
hours: i64,
minutes: i64,
seconds: f64,
) -> Interval
pub fn add_day_time( self, days: i32, hours: i64, minutes: i64, seconds: f64, ) -> Interval
Shortcut method to add day time part to the interval. Any units smaller than a microsecond will be truncated.
Sourcepub fn checked_add_day_time(
self,
days: i32,
hours: i64,
minutes: i64,
seconds: f64,
) -> Option<Interval>
pub fn checked_add_day_time( self, days: i32, hours: i64, minutes: i64, seconds: f64, ) -> Option<Interval>
Checked day time interval addition. Computes the interval and will return None
if a
overflow has occured. Any units smaller than a microsecond will be truncated.
Sourcepub fn add_year_month(self, year: i32, months: i32) -> Interval
pub fn add_year_month(self, year: i32, months: i32) -> Interval
Adds a year month interval.
Source§impl Interval
impl Interval
Sourcepub fn checked_sub(self, other_interval: Interval) -> Option<Interval>
pub fn checked_sub(self, other_interval: Interval) -> Option<Interval>
Checked interval subtraction. Computes Interval - Interval
and None
if there
was an underflow.
Sourcepub fn sub_day_time(
self,
days: i32,
hours: i64,
minutes: i64,
seconds: f64,
) -> Interval
pub fn sub_day_time( self, days: i32, hours: i64, minutes: i64, seconds: f64, ) -> Interval
Shortcut method to subtract day time part to the interval. Any units smaller than a microsecond will be truncated.
Sourcepub fn checked_sub_day_time(
self,
days: i32,
hours: i64,
minutes: i64,
seconds: f64,
) -> Option<Interval>
pub fn checked_sub_day_time( self, days: i32, hours: i64, minutes: i64, seconds: f64, ) -> Option<Interval>
Checked day time subtraction. Computes the interval and will return None
if a
overflow/underflow has occured. Any units smaller than a microsecond will be truncated.
Sourcepub fn sub_year_month(self, year: i32, months: i32) -> Interval
pub fn sub_year_month(self, year: i32, months: i32) -> Interval
Subtracts a year month interval.
Trait Implementations§
Source§impl<'a> FromSql<'a> for Interval
impl<'a> FromSql<'a> for Interval
Source§fn from_sql(
_: &Type,
raw: &'a [u8],
) -> Result<Self, Box<dyn Error + Sync + Send>>
fn from_sql( _: &Type, raw: &'a [u8], ) -> Result<Self, Box<dyn Error + Sync + Send>>
Type
in its binary format. Read moreSource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
.Source§impl ToSql for Interval
impl ToSql for Interval
Source§fn to_sql(
&self,
_: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql( &self, _: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read moreSource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
.Source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
Source§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
impl Copy for Interval
impl Eq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl Freeze for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnwindSafe for Interval
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
Source§impl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
Source§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self
as a ToSql
trait object.