Struct pg_interval::Interval
source · [−]Fields
months: i32
days: i32
microseconds: i64
Implementations
sourceimpl 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.
sourceimpl Interval
impl Interval
pub fn from_postgres(iso_str: &str) -> Result<Interval, ParseError>
sourceimpl 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.
sourceimpl 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.
sourceimpl 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
sourceimpl<'a> FromSql<'a> for Interval
impl<'a> FromSql<'a> for Interval
sourcefn 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 moresourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
. Read moresourceimpl ToSql for Interval
impl ToSql for Interval
sourcefn 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 moresourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
. Read moresourcefn 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>>
sourcefn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
impl Copy for Interval
impl Eq for Interval
impl StructuralEq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnwindSafe for Interval
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
sourcefn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self
as a ToSql
trait object.