#[repr(C)]pub struct DuckInterval {
pub months: i32,
pub days: i32,
pub micros: i64,
}Expand description
A DuckDB INTERVAL value, matching the C struct layout exactly.
§Memory layout
offset 0: months (i32) — number of calendar months
offset 4: days (i32) — number of calendar days
offset 8: micros (i64) — microseconds component
total: 16 bytes§Safety
This struct must remain #[repr(C)] with the exact field order above,
matching DuckDB’s duckdb_interval C struct.
Fields§
§months: i32Calendar months component.
days: i32Calendar days component.
micros: i64Sub-day microseconds component.
Implementations§
Source§impl DuckInterval
impl DuckInterval
Sourcepub fn to_micros(self) -> Option<i64>
pub fn to_micros(self) -> Option<i64>
Converts this interval to total microseconds with overflow checking.
Returns None if the result would overflow i64.
Month conversion uses 30 days/month, matching DuckDB’s approximation.
§Example
use quack_rs::interval::DuckInterval;
let iv = DuckInterval { months: 0, days: 1, micros: 500_000 };
assert_eq!(iv.to_micros(), Some(86_400_500_000_i64));Sourcepub fn to_micros_saturating(self) -> i64
pub fn to_micros_saturating(self) -> i64
Converts this interval to total microseconds, saturating on overflow.
§Example
use quack_rs::interval::DuckInterval;
let iv = DuckInterval { months: i32::MAX, days: i32::MAX, micros: i64::MAX };
assert_eq!(iv.to_micros_saturating(), i64::MAX);Trait Implementations§
Source§impl Clone for DuckInterval
impl Clone for DuckInterval
Source§fn clone(&self) -> DuckInterval
fn clone(&self) -> DuckInterval
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DuckInterval
impl Debug for DuckInterval
Source§impl Default for DuckInterval
impl Default for DuckInterval
Source§impl Hash for DuckInterval
impl Hash for DuckInterval
Source§impl PartialEq for DuckInterval
impl PartialEq for DuckInterval
impl Copy for DuckInterval
impl Eq for DuckInterval
impl StructuralPartialEq for DuckInterval
Auto Trait Implementations§
impl Freeze for DuckInterval
impl RefUnwindSafe for DuckInterval
impl Send for DuckInterval
impl Sync for DuckInterval
impl Unpin for DuckInterval
impl UnsafeUnpin for DuckInterval
impl UnwindSafe for DuckInterval
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
Mutably borrows from an owned value. Read more