Enforces "return self not must use" lint

pull/559/head
Tpt 2 years ago committed by Thomas Tanon
parent 86f14ce96f
commit 001b6e07b7
  1. 1
      lib/oxsdatatypes/src/boolean.rs
  2. 102
      lib/oxsdatatypes/src/date_time.rs
  3. 17
      lib/oxsdatatypes/src/decimal.rs
  4. 9
      lib/oxsdatatypes/src/double.rs
  5. 15
      lib/oxsdatatypes/src/duration.rs
  6. 9
      lib/oxsdatatypes/src/float.rs
  7. 13
      lib/oxsdatatypes/src/integer.rs
  8. 1
      lib/oxsdatatypes/src/lib.rs
  9. 1
      lib/src/lib.rs
  10. 3
      lib/src/storage/mod.rs
  11. 4
      lib/src/store.rs

@ -14,6 +14,7 @@ pub struct Boolean {
impl Boolean { impl Boolean {
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self == other self == other
} }

@ -52,6 +52,7 @@ impl DateTime {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -60,47 +61,55 @@ impl DateTime {
/// [fn:year-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-year-from-dateTime) /// [fn:year-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-year-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn year(self) -> i64 { pub fn year(self) -> i64 {
self.timestamp.year() self.timestamp.year()
} }
/// [fn:month-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-month-from-dateTime) /// [fn:month-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-month-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn month(self) -> u8 { pub fn month(self) -> u8 {
self.timestamp.month() self.timestamp.month()
} }
/// [fn:day-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-day-from-dateTime) /// [fn:day-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-day-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn day(self) -> u8 { pub fn day(self) -> u8 {
self.timestamp.day() self.timestamp.day()
} }
/// [fn:hour-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-dateTime) /// [fn:hour-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn hour(self) -> u8 { pub fn hour(self) -> u8 {
self.timestamp.hour() self.timestamp.hour()
} }
/// [fn:minute-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-dateTime) /// [fn:minute-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn minute(self) -> u8 { pub fn minute(self) -> u8 {
self.timestamp.minute() self.timestamp.minute()
} }
/// [fn:second-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-dateTime) /// [fn:second-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn second(self) -> Decimal { pub fn second(self) -> Decimal {
self.timestamp.second() self.timestamp.second()
} }
/// [fn:timezone-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-dateTime) /// [fn:timezone-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn timezone(self) -> Option<DayTimeDuration> { pub fn timezone(self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(self) -> Option<TimezoneOffset> { pub fn timezone_offset(self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
@ -119,18 +128,21 @@ impl DateTime {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// [op:subtract-dateTimes](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dateTimes) /// [op:subtract-dateTimes](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dateTimes)
#[inline] #[inline]
#[must_use]
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<DayTimeDuration> { pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<DayTimeDuration> {
self.timestamp.checked_sub(rhs.into().timestamp) self.timestamp.checked_sub(rhs.into().timestamp)
} }
/// [op:add-yearMonthDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-dateTime) /// [op:add-yearMonthDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-dateTime)
#[inline] #[inline]
#[must_use]
pub fn checked_add_year_month_duration( pub fn checked_add_year_month_duration(
self, self,
rhs: impl Into<YearMonthDuration>, rhs: impl Into<YearMonthDuration>,
@ -140,6 +152,7 @@ impl DateTime {
/// [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-dateTime) /// [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-dateTime)
#[inline] #[inline]
#[must_use]
pub fn checked_add_day_time_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_add_day_time_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
let rhs = rhs.into(); let rhs = rhs.into();
Some(Self { Some(Self {
@ -149,6 +162,7 @@ impl DateTime {
/// [op:add-yearMonthDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-dateTime) and [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-dateTime) /// [op:add-yearMonthDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-dateTime) and [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-dateTime)
#[inline] #[inline]
#[must_use]
pub fn checked_add_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_add_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
let rhs = rhs.into(); let rhs = rhs.into();
if let Ok(rhs) = DayTimeDuration::try_from(rhs) { if let Ok(rhs) = DayTimeDuration::try_from(rhs) {
@ -163,6 +177,7 @@ impl DateTime {
/// [op:subtract-yearMonthDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-dateTime) /// [op:subtract-yearMonthDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_year_month_duration( pub fn checked_sub_year_month_duration(
self, self,
rhs: impl Into<YearMonthDuration>, rhs: impl Into<YearMonthDuration>,
@ -172,6 +187,7 @@ impl DateTime {
/// [op:subtract-dayTimeDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-dateTime) /// [op:subtract-dayTimeDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> { pub fn checked_sub_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> {
let rhs = rhs.into(); let rhs = rhs.into();
Some(Self { Some(Self {
@ -181,6 +197,7 @@ impl DateTime {
/// [op:subtract-yearMonthDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-dateTime) and [op:subtract-dayTimeDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-dateTime) /// [op:subtract-yearMonthDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-dateTime) and [op:subtract-dayTimeDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-dateTime)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_sub_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
let rhs = rhs.into(); let rhs = rhs.into();
if let Ok(rhs) = DayTimeDuration::try_from(rhs) { if let Ok(rhs) = DayTimeDuration::try_from(rhs) {
@ -198,6 +215,7 @@ impl DateTime {
/// [fn:adjust-dateTime-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-dateTime-to-timezone) /// [fn:adjust-dateTime-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-dateTime-to-timezone)
#[inline] #[inline]
#[must_use]
pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(Self { Some(Self {
timestamp: self.timestamp.adjust(timezone_offset)?, timestamp: self.timestamp.adjust(timezone_offset)?,
@ -206,6 +224,7 @@ impl DateTime {
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -300,6 +319,7 @@ impl Time {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -314,52 +334,61 @@ impl Time {
/// [fn:hour-from-time](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-time) /// [fn:hour-from-time](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-time)
#[inline] #[inline]
#[must_use]
pub fn hour(self) -> u8 { pub fn hour(self) -> u8 {
self.timestamp.hour() self.timestamp.hour()
} }
/// [fn:minute-from-time](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-time) /// [fn:minute-from-time](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-time)
#[inline] #[inline]
#[must_use]
pub fn minute(self) -> u8 { pub fn minute(self) -> u8 {
self.timestamp.minute() self.timestamp.minute()
} }
/// [fn:second-from-time](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-time) /// [fn:second-from-time](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-time)
#[inline] #[inline]
#[must_use]
pub fn second(self) -> Decimal { pub fn second(self) -> Decimal {
self.timestamp.second() self.timestamp.second()
} }
/// [fn:timezone-from-time](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-time) /// [fn:timezone-from-time](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-time)
#[inline] #[inline]
#[must_use]
pub fn timezone(self) -> Option<DayTimeDuration> { pub fn timezone(self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(self) -> Option<TimezoneOffset> { pub fn timezone_offset(self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// [op:subtract-times](https://www.w3.org/TR/xpath-functions-31/#func-subtract-times) /// [op:subtract-times](https://www.w3.org/TR/xpath-functions-31/#func-subtract-times)
#[inline] #[inline]
#[must_use]
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<DayTimeDuration> { pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<DayTimeDuration> {
self.timestamp.checked_sub(rhs.into().timestamp) self.timestamp.checked_sub(rhs.into().timestamp)
} }
/// [op:add-dayTimeDuration-to-time](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-time) /// [op:add-dayTimeDuration-to-time](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-time)
#[inline] #[inline]
#[must_use]
pub fn checked_add_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> { pub fn checked_add_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> {
self.checked_add_duration(Duration::from(rhs.into())) self.checked_add_duration(Duration::from(rhs.into()))
} }
/// [op:add-dayTimeDuration-to-time](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-time) /// [op:add-dayTimeDuration-to-time](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-time)
#[inline] #[inline]
#[must_use]
pub fn checked_add_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_add_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
DateTime::new( DateTime::new(
1972, 1972,
@ -378,12 +407,14 @@ impl Time {
/// [op:subtract-dayTimeDuration-from-time](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-time) /// [op:subtract-dayTimeDuration-from-time](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-time)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> { pub fn checked_sub_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> {
self.checked_sub_duration(Duration::from(rhs.into())) self.checked_sub_duration(Duration::from(rhs.into()))
} }
/// [op:subtract-dayTimeDuration-from-time](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-time) /// [op:subtract-dayTimeDuration-from-time](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-time)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_sub_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
DateTime::new( DateTime::new(
1972, 1972,
@ -402,6 +433,7 @@ impl Time {
// [fn:adjust-time-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-time-to-timezone) // [fn:adjust-time-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-time-to-timezone)
#[inline] #[inline]
#[must_use]
pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
DateTime::new( DateTime::new(
1972, 1972,
@ -420,6 +452,7 @@ impl Time {
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -501,6 +534,7 @@ impl Date {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -515,46 +549,54 @@ impl Date {
/// [fn:year-from-date](https://www.w3.org/TR/xpath-functions-31/#func-year-from-date) /// [fn:year-from-date](https://www.w3.org/TR/xpath-functions-31/#func-year-from-date)
#[inline] #[inline]
#[must_use]
pub fn year(self) -> i64 { pub fn year(self) -> i64 {
self.timestamp.year() self.timestamp.year()
} }
/// [fn:month-from-date](https://www.w3.org/TR/xpath-functions-31/#func-month-from-date) /// [fn:month-from-date](https://www.w3.org/TR/xpath-functions-31/#func-month-from-date)
#[inline] #[inline]
#[must_use]
pub fn month(self) -> u8 { pub fn month(self) -> u8 {
self.timestamp.month() self.timestamp.month()
} }
/// [fn:day-from-date](https://www.w3.org/TR/xpath-functions-31/#func-day-from-date) /// [fn:day-from-date](https://www.w3.org/TR/xpath-functions-31/#func-day-from-date)
#[inline] #[inline]
#[must_use]
pub fn day(self) -> u8 { pub fn day(self) -> u8 {
self.timestamp.day() self.timestamp.day()
} }
/// [fn:timezone-from-date](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-date) /// [fn:timezone-from-date](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-date)
#[inline] #[inline]
#[must_use]
pub fn timezone(self) -> Option<DayTimeDuration> { pub fn timezone(self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(self) -> Option<TimezoneOffset> { pub fn timezone_offset(self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// [op:subtract-dates](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dates) /// [op:subtract-dates](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dates)
#[inline] #[inline]
#[must_use]
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<DayTimeDuration> { pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<DayTimeDuration> {
self.timestamp.checked_sub(rhs.into().timestamp) self.timestamp.checked_sub(rhs.into().timestamp)
} }
/// [op:add-yearMonthDuration-to-date](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-date) /// [op:add-yearMonthDuration-to-date](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-date)
#[inline] #[inline]
#[must_use]
pub fn checked_add_year_month_duration( pub fn checked_add_year_month_duration(
self, self,
rhs: impl Into<YearMonthDuration>, rhs: impl Into<YearMonthDuration>,
@ -564,12 +606,14 @@ impl Date {
/// [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-date) /// [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-date)
#[inline] #[inline]
#[must_use]
pub fn checked_add_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> { pub fn checked_add_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> {
self.checked_add_duration(Duration::from(rhs.into())) self.checked_add_duration(Duration::from(rhs.into()))
} }
/// [op:add-yearMonthDuration-to-date](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-date) and [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-date) /// [op:add-yearMonthDuration-to-date](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-date) and [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-date)
#[inline] #[inline]
#[must_use]
pub fn checked_add_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_add_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
DateTime::try_from(self) DateTime::try_from(self)
.ok()? .ok()?
@ -580,6 +624,7 @@ impl Date {
/// [op:subtract-yearMonthDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-date) /// [op:subtract-yearMonthDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-date)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_year_month_duration( pub fn checked_sub_year_month_duration(
self, self,
rhs: impl Into<YearMonthDuration>, rhs: impl Into<YearMonthDuration>,
@ -589,12 +634,14 @@ impl Date {
/// [op:subtract-dayTimeDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-date) /// [op:subtract-dayTimeDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-date)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> { pub fn checked_sub_day_time_duration(self, rhs: impl Into<DayTimeDuration>) -> Option<Self> {
self.checked_sub_duration(Duration::from(rhs.into())) self.checked_sub_duration(Duration::from(rhs.into()))
} }
/// [op:subtract-yearMonthDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-date) and [op:subtract-dayTimeDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-date) /// [op:subtract-yearMonthDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-date) and [op:subtract-dayTimeDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-date)
#[inline] #[inline]
#[must_use]
pub fn checked_sub_duration(self, rhs: impl Into<Duration>) -> Option<Self> { pub fn checked_sub_duration(self, rhs: impl Into<Duration>) -> Option<Self> {
DateTime::try_from(self) DateTime::try_from(self)
.ok()? .ok()?
@ -605,6 +652,7 @@ impl Date {
// [fn:adjust-date-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-date-to-timezone) // [fn:adjust-date-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-date-to-timezone)
#[inline] #[inline]
#[must_use]
pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
DateTime::new( DateTime::new(
self.year(), self.year(),
@ -623,6 +671,7 @@ impl Date {
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -696,6 +745,7 @@ impl GYearMonth {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -703,26 +753,31 @@ impl GYearMonth {
} }
#[inline] #[inline]
#[must_use]
pub fn year(self) -> i64 { pub fn year(self) -> i64 {
self.timestamp.year() self.timestamp.year()
} }
#[inline] #[inline]
#[must_use]
pub fn month(self) -> u8 { pub fn month(self) -> u8 {
self.timestamp.month() self.timestamp.month()
} }
#[inline] #[inline]
#[must_use]
pub fn timezone(self) -> Option<DayTimeDuration> { pub fn timezone(self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(self) -> Option<TimezoneOffset> { pub fn timezone_offset(self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(Self { Some(Self {
timestamp: self.timestamp.adjust(timezone_offset)?, timestamp: self.timestamp.adjust(timezone_offset)?,
@ -730,12 +785,14 @@ impl GYearMonth {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -817,6 +874,7 @@ impl GYear {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -824,21 +882,25 @@ impl GYear {
} }
#[inline] #[inline]
#[must_use]
pub fn year(self) -> i64 { pub fn year(self) -> i64 {
self.timestamp.year() self.timestamp.year()
} }
#[inline] #[inline]
#[must_use]
pub fn timezone(self) -> Option<DayTimeDuration> { pub fn timezone(self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(self) -> Option<TimezoneOffset> { pub fn timezone_offset(self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(Self { Some(Self {
timestamp: self.timestamp.adjust(timezone_offset)?, timestamp: self.timestamp.adjust(timezone_offset)?,
@ -846,12 +908,14 @@ impl GYear {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -939,6 +1003,7 @@ impl GMonthDay {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -946,26 +1011,31 @@ impl GMonthDay {
} }
#[inline] #[inline]
#[must_use]
pub fn month(&self) -> u8 { pub fn month(&self) -> u8 {
self.timestamp.month() self.timestamp.month()
} }
#[inline] #[inline]
#[must_use]
pub fn day(&self) -> u8 { pub fn day(&self) -> u8 {
self.timestamp.day() self.timestamp.day()
} }
#[inline] #[inline]
#[must_use]
pub fn timezone(&self) -> Option<DayTimeDuration> { pub fn timezone(&self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(&self) -> Option<TimezoneOffset> { pub fn timezone_offset(&self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(Self { Some(Self {
timestamp: self.timestamp.adjust(timezone_offset)?, timestamp: self.timestamp.adjust(timezone_offset)?,
@ -973,12 +1043,14 @@ impl GMonthDay {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -1056,6 +1128,7 @@ impl GMonth {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -1063,21 +1136,25 @@ impl GMonth {
} }
#[inline] #[inline]
#[must_use]
pub fn month(&self) -> u8 { pub fn month(&self) -> u8 {
self.timestamp.month() self.timestamp.month()
} }
#[inline] #[inline]
#[must_use]
pub fn timezone(&self) -> Option<DayTimeDuration> { pub fn timezone(&self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(&self) -> Option<TimezoneOffset> { pub fn timezone_offset(&self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(Self { Some(Self {
timestamp: self.timestamp.adjust(timezone_offset)?, timestamp: self.timestamp.adjust(timezone_offset)?,
@ -1085,12 +1162,14 @@ impl GMonth {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -1182,6 +1261,7 @@ impl GDay {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 18]) -> Self { pub fn from_be_bytes(bytes: [u8; 18]) -> Self {
Self { Self {
timestamp: Timestamp::from_be_bytes(bytes), timestamp: Timestamp::from_be_bytes(bytes),
@ -1189,21 +1269,25 @@ impl GDay {
} }
#[inline] #[inline]
#[must_use]
pub fn day(&self) -> u8 { pub fn day(&self) -> u8 {
self.timestamp.day() self.timestamp.day()
} }
#[inline] #[inline]
#[must_use]
pub fn timezone(&self) -> Option<DayTimeDuration> { pub fn timezone(&self) -> Option<DayTimeDuration> {
Some(self.timezone_offset()?.into()) Some(self.timezone_offset()?.into())
} }
#[inline] #[inline]
#[must_use]
pub fn timezone_offset(&self) -> Option<TimezoneOffset> { pub fn timezone_offset(&self) -> Option<TimezoneOffset> {
self.timestamp.timezone_offset() self.timestamp.timezone_offset()
} }
#[inline] #[inline]
#[must_use]
pub fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { pub fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(Self { Some(Self {
timestamp: self.timestamp.adjust(timezone_offset)?, timestamp: self.timestamp.adjust(timezone_offset)?,
@ -1211,12 +1295,14 @@ impl GDay {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 18] { pub fn to_be_bytes(self) -> [u8; 18] {
self.timestamp.to_be_bytes() self.timestamp.to_be_bytes()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.timestamp.is_identical_with(other.timestamp) self.timestamp.is_identical_with(other.timestamp)
} }
@ -1293,6 +1379,7 @@ impl TimezoneOffset {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 2]) -> Self { pub fn from_be_bytes(bytes: [u8; 2]) -> Self {
Self { Self {
offset: i16::from_be_bytes(bytes), offset: i16::from_be_bytes(bytes),
@ -1300,6 +1387,7 @@ impl TimezoneOffset {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 2] { pub fn to_be_bytes(self) -> [u8; 2] {
self.offset.to_be_bytes() self.offset.to_be_bytes()
} }
@ -1486,6 +1574,7 @@ impl Timestamp {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
#[inline] #[inline]
#[must_use]
fn year_month_day(&self) -> (i64, u8, u8) { fn year_month_day(&self) -> (i64, u8, u8) {
let mut days = (self.value.as_i128() let mut days = (self.value.as_i128()
+ i128::from(self.timezone_offset.unwrap_or(TimezoneOffset::UTC).offset) * 60) + i128::from(self.timezone_offset.unwrap_or(TimezoneOffset::UTC).offset) * 60)
@ -1537,18 +1626,21 @@ impl Timestamp {
} }
#[inline] #[inline]
#[must_use]
fn year(&self) -> i64 { fn year(&self) -> i64 {
let (year, _, _) = self.year_month_day(); let (year, _, _) = self.year_month_day();
year year
} }
#[inline] #[inline]
#[must_use]
fn month(&self) -> u8 { fn month(&self) -> u8 {
let (_, month, _) = self.year_month_day(); let (_, month, _) = self.year_month_day();
month month
} }
#[inline] #[inline]
#[must_use]
fn day(&self) -> u8 { fn day(&self) -> u8 {
let (_, _, day) = self.year_month_day(); let (_, _, day) = self.year_month_day();
day day
@ -1556,6 +1648,7 @@ impl Timestamp {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
#[inline] #[inline]
#[must_use]
fn hour(&self) -> u8 { fn hour(&self) -> u8 {
(((self.value.as_i128() (((self.value.as_i128()
+ i128::from(self.timezone_offset.unwrap_or(TimezoneOffset::UTC).offset) * 60) + i128::from(self.timezone_offset.unwrap_or(TimezoneOffset::UTC).offset) * 60)
@ -1565,6 +1658,7 @@ impl Timestamp {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
#[inline] #[inline]
#[must_use]
fn minute(&self) -> u8 { fn minute(&self) -> u8 {
(((self.value.as_i128() (((self.value.as_i128()
+ i128::from(self.timezone_offset.unwrap_or(TimezoneOffset::UTC).offset) * 60) + i128::from(self.timezone_offset.unwrap_or(TimezoneOffset::UTC).offset) * 60)
@ -1573,16 +1667,19 @@ impl Timestamp {
} }
#[inline] #[inline]
#[must_use]
fn second(&self) -> Decimal { fn second(&self) -> Decimal {
self.value.checked_rem_euclid(60).unwrap().abs() self.value.checked_rem_euclid(60).unwrap().abs()
} }
#[inline] #[inline]
#[must_use]
const fn timezone_offset(&self) -> Option<TimezoneOffset> { const fn timezone_offset(&self) -> Option<TimezoneOffset> {
self.timezone_offset self.timezone_offset
} }
#[inline] #[inline]
#[must_use]
fn checked_add_seconds(&self, seconds: impl Into<Decimal>) -> Option<Self> { fn checked_add_seconds(&self, seconds: impl Into<Decimal>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_add(seconds.into())?, value: self.value.checked_add(seconds.into())?,
@ -1591,6 +1688,7 @@ impl Timestamp {
} }
#[inline] #[inline]
#[must_use]
fn checked_sub(&self, rhs: Self) -> Option<DayTimeDuration> { fn checked_sub(&self, rhs: Self) -> Option<DayTimeDuration> {
match (self.timezone_offset, rhs.timezone_offset) { match (self.timezone_offset, rhs.timezone_offset) {
(Some(_), Some(_)) | (None, None) => { (Some(_), Some(_)) | (None, None) => {
@ -1601,6 +1699,7 @@ impl Timestamp {
} }
#[inline] #[inline]
#[must_use]
fn checked_sub_seconds(&self, seconds: Decimal) -> Option<Self> { fn checked_sub_seconds(&self, seconds: Decimal) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_sub(seconds)?, value: self.value.checked_sub(seconds)?,
@ -1609,6 +1708,7 @@ impl Timestamp {
} }
#[inline] #[inline]
#[must_use]
fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> { fn adjust(&self, timezone_offset: Option<TimezoneOffset>) -> Option<Self> {
Some(if let Some(from_timezone) = self.timezone_offset { Some(if let Some(from_timezone) = self.timezone_offset {
if let Some(to_timezone) = timezone_offset { if let Some(to_timezone) = timezone_offset {
@ -1638,6 +1738,7 @@ impl Timestamp {
} }
#[inline] #[inline]
#[must_use]
fn to_be_bytes(self) -> [u8; 18] { fn to_be_bytes(self) -> [u8; 18] {
let mut bytes = [0; 18]; let mut bytes = [0; 18];
bytes[0..16].copy_from_slice(&self.value.to_be_bytes()); bytes[0..16].copy_from_slice(&self.value.to_be_bytes());
@ -1650,6 +1751,7 @@ impl Timestamp {
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.value == other.value && self.timezone_offset == other.timezone_offset self.value == other.value && self.timezone_offset == other.timezone_offset
} }

@ -33,6 +33,7 @@ impl Decimal {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 16]) -> Self { pub fn from_be_bytes(bytes: [u8; 16]) -> Self {
Self { Self {
value: i128::from_be_bytes(bytes), value: i128::from_be_bytes(bytes),
@ -40,12 +41,14 @@ impl Decimal {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 16] { pub fn to_be_bytes(self) -> [u8; 16] {
self.value.to_be_bytes() self.value.to_be_bytes()
} }
/// [op:numeric-add](https://www.w3.org/TR/xpath-functions-31/#func-numeric-add) /// [op:numeric-add](https://www.w3.org/TR/xpath-functions-31/#func-numeric-add)
#[inline] #[inline]
#[must_use]
pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_add(rhs.into().value)?, value: self.value.checked_add(rhs.into().value)?,
@ -54,6 +57,7 @@ impl Decimal {
/// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions-31/#func-numeric-subtract) /// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions-31/#func-numeric-subtract)
#[inline] #[inline]
#[must_use]
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_sub(rhs.into().value)?, value: self.value.checked_sub(rhs.into().value)?,
@ -62,6 +66,7 @@ impl Decimal {
/// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions-31/#func-numeric-multiply) /// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions-31/#func-numeric-multiply)
#[inline] #[inline]
#[must_use]
pub fn checked_mul(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_mul(self, rhs: impl Into<Self>) -> Option<Self> {
// Idea: we shift right as much as possible to keep as much precision as possible // Idea: we shift right as much as possible to keep as much precision as possible
// Do the multiplication and do the required left shift // Do the multiplication and do the required left shift
@ -94,6 +99,7 @@ impl Decimal {
/// [op:numeric-divide](https://www.w3.org/TR/xpath-functions-31/#func-numeric-divide) /// [op:numeric-divide](https://www.w3.org/TR/xpath-functions-31/#func-numeric-divide)
#[inline] #[inline]
#[must_use]
pub fn checked_div(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_div(self, rhs: impl Into<Self>) -> Option<Self> {
// Idea: we shift the dividend left as much as possible to keep as much precision as possible // Idea: we shift the dividend left as much as possible to keep as much precision as possible
// And we shift right the divisor as much as possible // And we shift right the divisor as much as possible
@ -127,6 +133,7 @@ impl Decimal {
/// [op:numeric-mod](https://www.w3.org/TR/xpath-functions-31/#func-numeric-mod) /// [op:numeric-mod](https://www.w3.org/TR/xpath-functions-31/#func-numeric-mod)
#[inline] #[inline]
#[must_use]
pub fn checked_rem(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_rem(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_rem(rhs.into().value)?, value: self.value.checked_rem(rhs.into().value)?,
@ -134,6 +141,7 @@ impl Decimal {
} }
#[inline] #[inline]
#[must_use]
pub fn checked_rem_euclid(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_rem_euclid(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_rem_euclid(rhs.into().value)?, value: self.value.checked_rem_euclid(rhs.into().value)?,
@ -142,6 +150,7 @@ impl Decimal {
/// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions-31/#func-numeric-unary-minus) /// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions-31/#func-numeric-unary-minus)
#[inline] #[inline]
#[must_use]
pub fn checked_neg(self) -> Option<Self> { pub fn checked_neg(self) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_neg()?, value: self.value.checked_neg()?,
@ -150,6 +159,7 @@ impl Decimal {
/// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs) /// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs)
#[inline] #[inline]
#[must_use]
pub const fn abs(self) -> Self { pub const fn abs(self) -> Self {
Self { Self {
value: self.value.abs(), value: self.value.abs(),
@ -158,6 +168,7 @@ impl Decimal {
/// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round) /// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round)
#[inline] #[inline]
#[must_use]
pub fn round(self) -> Self { pub fn round(self) -> Self {
let value = self.value / DECIMAL_PART_POW_MINUS_ONE; let value = self.value / DECIMAL_PART_POW_MINUS_ONE;
Self { Self {
@ -171,6 +182,7 @@ impl Decimal {
/// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling) /// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling)
#[inline] #[inline]
#[must_use]
pub fn ceil(self) -> Self { pub fn ceil(self) -> Self {
Self { Self {
value: if self.value >= 0 && self.value % DECIMAL_PART_POW != 0 { value: if self.value >= 0 && self.value % DECIMAL_PART_POW != 0 {
@ -183,6 +195,7 @@ impl Decimal {
/// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor) /// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor)
#[inline] #[inline]
#[must_use]
pub fn floor(self) -> Self { pub fn floor(self) -> Self {
Self { Self {
value: if self.value >= 0 || self.value % DECIMAL_PART_POW == 0 { value: if self.value >= 0 || self.value % DECIMAL_PART_POW == 0 {
@ -194,22 +207,26 @@ impl Decimal {
} }
#[inline] #[inline]
#[must_use]
pub const fn is_negative(self) -> bool { pub const fn is_negative(self) -> bool {
self.value < 0 self.value < 0
} }
#[inline] #[inline]
#[must_use]
pub const fn is_positive(self) -> bool { pub const fn is_positive(self) -> bool {
self.value > 0 self.value > 0
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self == other self == other
} }
#[inline] #[inline]
#[must_use]
pub(super) const fn as_i128(self) -> i128 { pub(super) const fn as_i128(self) -> i128 {
self.value / DECIMAL_PART_POW self.value / DECIMAL_PART_POW
} }

@ -18,6 +18,7 @@ pub struct Double {
impl Double { impl Double {
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 8]) -> Self { pub fn from_be_bytes(bytes: [u8; 8]) -> Self {
Self { Self {
value: f64::from_be_bytes(bytes), value: f64::from_be_bytes(bytes),
@ -25,46 +26,54 @@ impl Double {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 8] { pub fn to_be_bytes(self) -> [u8; 8] {
self.value.to_be_bytes() self.value.to_be_bytes()
} }
/// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs) /// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs)
#[inline] #[inline]
#[must_use]
pub fn abs(self) -> Self { pub fn abs(self) -> Self {
self.value.abs().into() self.value.abs().into()
} }
/// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling) /// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling)
#[inline] #[inline]
#[must_use]
pub fn ceil(self) -> Self { pub fn ceil(self) -> Self {
self.value.ceil().into() self.value.ceil().into()
} }
/// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor) /// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor)
#[inline] #[inline]
#[must_use]
pub fn floor(self) -> Self { pub fn floor(self) -> Self {
self.value.floor().into() self.value.floor().into()
} }
/// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round) /// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round)
#[inline] #[inline]
#[must_use]
pub fn round(self) -> Self { pub fn round(self) -> Self {
self.value.round().into() self.value.round().into()
} }
#[inline] #[inline]
#[must_use]
pub fn is_nan(self) -> bool { pub fn is_nan(self) -> bool {
self.value.is_nan() self.value.is_nan()
} }
#[inline] #[inline]
#[must_use]
pub fn is_finite(self) -> bool { pub fn is_finite(self) -> bool {
self.value.is_finite() self.value.is_finite()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.value.to_ne_bytes() == other.value.to_ne_bytes() self.value.to_ne_bytes() == other.value.to_ne_bytes()
} }

@ -17,6 +17,7 @@ pub struct Duration {
impl Duration { impl Duration {
#[inline] #[inline]
#[must_use]
pub fn new(months: impl Into<i64>, seconds: impl Into<Decimal>) -> Self { pub fn new(months: impl Into<i64>, seconds: impl Into<Decimal>) -> Self {
Self { Self {
year_month: YearMonthDuration::new(months), year_month: YearMonthDuration::new(months),
@ -25,6 +26,7 @@ impl Duration {
} }
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 24]) -> Self { pub fn from_be_bytes(bytes: [u8; 24]) -> Self {
Self { Self {
year_month: YearMonthDuration::from_be_bytes(bytes[0..8].try_into().unwrap()), year_month: YearMonthDuration::from_be_bytes(bytes[0..8].try_into().unwrap()),
@ -34,51 +36,60 @@ impl Duration {
/// [fn:years-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-years-from-duration) /// [fn:years-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-years-from-duration)
#[inline] #[inline]
#[must_use]
pub fn years(self) -> i64 { pub fn years(self) -> i64 {
self.year_month.years() self.year_month.years()
} }
/// [fn:months-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-months-from-duration) /// [fn:months-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-months-from-duration)
#[inline] #[inline]
#[must_use]
pub fn months(self) -> i64 { pub fn months(self) -> i64 {
self.year_month.months() self.year_month.months()
} }
/// [fn:days-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-days-from-duration) /// [fn:days-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-days-from-duration)
#[inline] #[inline]
#[must_use]
pub fn days(self) -> i64 { pub fn days(self) -> i64 {
self.day_time.days() self.day_time.days()
} }
/// [fn:hours-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-duration) /// [fn:hours-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-duration)
#[inline] #[inline]
#[must_use]
pub fn hours(self) -> i64 { pub fn hours(self) -> i64 {
self.day_time.hours() self.day_time.hours()
} }
/// [fn:minutes-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-duration) /// [fn:minutes-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-duration)
#[inline] #[inline]
#[must_use]
pub fn minutes(self) -> i64 { pub fn minutes(self) -> i64 {
self.day_time.minutes() self.day_time.minutes()
} }
/// [fn:seconds-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-duration) /// [fn:seconds-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-duration)
#[inline] #[inline]
#[must_use]
pub fn seconds(self) -> Decimal { pub fn seconds(self) -> Decimal {
self.day_time.seconds() self.day_time.seconds()
} }
#[inline] #[inline]
#[must_use]
pub(super) const fn all_months(self) -> i64 { pub(super) const fn all_months(self) -> i64 {
self.year_month.all_months() self.year_month.all_months()
} }
#[inline] #[inline]
#[must_use]
pub(super) const fn all_seconds(self) -> Decimal { pub(super) const fn all_seconds(self) -> Decimal {
self.day_time.all_seconds() self.day_time.all_seconds()
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 24] { pub fn to_be_bytes(self) -> [u8; 24] {
let mut bytes = [0; 24]; let mut bytes = [0; 24];
bytes[0..8].copy_from_slice(&self.year_month.to_be_bytes()); bytes[0..8].copy_from_slice(&self.year_month.to_be_bytes());
@ -88,6 +99,7 @@ impl Duration {
/// [op:add-yearMonthDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDurations) and [op:add-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDurations) /// [op:add-yearMonthDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDurations) and [op:add-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDurations)
#[inline] #[inline]
#[must_use]
pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self> {
let rhs = rhs.into(); let rhs = rhs.into();
Some(Self { Some(Self {
@ -98,6 +110,7 @@ impl Duration {
/// [op:subtract-yearMonthDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDurations) and [op:subtract-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDurations) /// [op:subtract-yearMonthDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDurations) and [op:subtract-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDurations)
#[inline] #[inline]
#[must_use]
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self> {
let rhs = rhs.into(); let rhs = rhs.into();
Some(Self { Some(Self {
@ -107,6 +120,7 @@ impl Duration {
} }
#[inline] #[inline]
#[must_use]
pub fn checked_neg(self) -> Option<Self> { pub fn checked_neg(self) -> Option<Self> {
Some(Self { Some(Self {
year_month: self.year_month.checked_neg()?, year_month: self.year_month.checked_neg()?,
@ -116,6 +130,7 @@ impl Duration {
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self == other self == other
} }

@ -18,6 +18,7 @@ pub struct Float {
impl Float { impl Float {
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 4]) -> Self { pub fn from_be_bytes(bytes: [u8; 4]) -> Self {
Self { Self {
value: f32::from_be_bytes(bytes), value: f32::from_be_bytes(bytes),
@ -25,46 +26,54 @@ impl Float {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 4] { pub fn to_be_bytes(self) -> [u8; 4] {
self.value.to_be_bytes() self.value.to_be_bytes()
} }
/// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs) /// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs)
#[inline] #[inline]
#[must_use]
pub fn abs(self) -> Self { pub fn abs(self) -> Self {
self.value.abs().into() self.value.abs().into()
} }
/// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling) /// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling)
#[inline] #[inline]
#[must_use]
pub fn ceil(self) -> Self { pub fn ceil(self) -> Self {
self.value.ceil().into() self.value.ceil().into()
} }
/// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor) /// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor)
#[inline] #[inline]
#[must_use]
pub fn floor(self) -> Self { pub fn floor(self) -> Self {
self.value.floor().into() self.value.floor().into()
} }
/// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round) /// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round)
#[inline] #[inline]
#[must_use]
pub fn round(self) -> Self { pub fn round(self) -> Self {
self.value.round().into() self.value.round().into()
} }
#[inline] #[inline]
#[must_use]
pub fn is_nan(self) -> bool { pub fn is_nan(self) -> bool {
self.value.is_nan() self.value.is_nan()
} }
#[inline] #[inline]
#[must_use]
pub fn is_finite(self) -> bool { pub fn is_finite(self) -> bool {
self.value.is_finite() self.value.is_finite()
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self.value.to_ne_bytes() == other.value.to_ne_bytes() self.value.to_ne_bytes() == other.value.to_ne_bytes()
} }

@ -14,6 +14,7 @@ pub struct Integer {
impl Integer { impl Integer {
#[inline] #[inline]
#[must_use]
pub fn from_be_bytes(bytes: [u8; 8]) -> Self { pub fn from_be_bytes(bytes: [u8; 8]) -> Self {
Self { Self {
value: i64::from_be_bytes(bytes), value: i64::from_be_bytes(bytes),
@ -21,12 +22,14 @@ impl Integer {
} }
#[inline] #[inline]
#[must_use]
pub fn to_be_bytes(self) -> [u8; 8] { pub fn to_be_bytes(self) -> [u8; 8] {
self.value.to_be_bytes() self.value.to_be_bytes()
} }
/// [op:numeric-add](https://www.w3.org/TR/xpath-functions-31/#func-numeric-add) /// [op:numeric-add](https://www.w3.org/TR/xpath-functions-31/#func-numeric-add)
#[inline] #[inline]
#[must_use]
pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_add(rhs.into().value)?, value: self.value.checked_add(rhs.into().value)?,
@ -35,6 +38,7 @@ impl Integer {
/// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions-31/#func-numeric-subtract) /// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions-31/#func-numeric-subtract)
#[inline] #[inline]
#[must_use]
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_sub(rhs.into().value)?, value: self.value.checked_sub(rhs.into().value)?,
@ -43,6 +47,7 @@ impl Integer {
/// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions-31/#func-numeric-multiply) /// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions-31/#func-numeric-multiply)
#[inline] #[inline]
#[must_use]
pub fn checked_mul(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_mul(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_mul(rhs.into().value)?, value: self.value.checked_mul(rhs.into().value)?,
@ -51,6 +56,7 @@ impl Integer {
/// [op:numeric-integer-divide](https://www.w3.org/TR/xpath-functions-31/#func-numeric-integer-divide) /// [op:numeric-integer-divide](https://www.w3.org/TR/xpath-functions-31/#func-numeric-integer-divide)
#[inline] #[inline]
#[must_use]
pub fn checked_div(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_div(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_div(rhs.into().value)?, value: self.value.checked_div(rhs.into().value)?,
@ -59,6 +65,7 @@ impl Integer {
/// [op:numeric-mod](https://www.w3.org/TR/xpath-functions-31/#func-numeric-mod) /// [op:numeric-mod](https://www.w3.org/TR/xpath-functions-31/#func-numeric-mod)
#[inline] #[inline]
#[must_use]
pub fn checked_rem(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_rem(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_rem(rhs.into().value)?, value: self.value.checked_rem(rhs.into().value)?,
@ -66,6 +73,7 @@ impl Integer {
} }
#[inline] #[inline]
#[must_use]
pub fn checked_rem_euclid(self, rhs: impl Into<Self>) -> Option<Self> { pub fn checked_rem_euclid(self, rhs: impl Into<Self>) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_rem_euclid(rhs.into().value)?, value: self.value.checked_rem_euclid(rhs.into().value)?,
@ -74,6 +82,7 @@ impl Integer {
/// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions-31/#func-numeric-unary-minus) /// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions-31/#func-numeric-unary-minus)
#[inline] #[inline]
#[must_use]
pub fn checked_neg(self) -> Option<Self> { pub fn checked_neg(self) -> Option<Self> {
Some(Self { Some(Self {
value: self.value.checked_neg()?, value: self.value.checked_neg()?,
@ -82,6 +91,7 @@ impl Integer {
/// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs) /// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs)
#[inline] #[inline]
#[must_use]
pub const fn abs(self) -> Self { pub const fn abs(self) -> Self {
Self { Self {
value: self.value.abs(), value: self.value.abs(),
@ -89,17 +99,20 @@ impl Integer {
} }
#[inline] #[inline]
#[must_use]
pub const fn is_negative(self) -> bool { pub const fn is_negative(self) -> bool {
self.value < 0 self.value < 0
} }
#[inline] #[inline]
#[must_use]
pub const fn is_positive(self) -> bool { pub const fn is_positive(self) -> bool {
self.value > 0 self.value > 0
} }
/// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity).
#[inline] #[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool { pub fn is_identical_with(self, other: Self) -> bool {
self == other self == other
} }

@ -3,7 +3,6 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/main/logo.svg")] #![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/main/logo.svg")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/main/logo.svg")] #![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/main/logo.svg")]
#![allow(clippy::return_self_not_must_use)]
mod boolean; mod boolean;
mod date_time; mod date_time;

@ -3,7 +3,6 @@
#![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/main/logo.svg")] #![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/main/logo.svg")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(test(attr(deny(warnings))))] #![doc(test(attr(deny(warnings))))]
#![allow(clippy::return_self_not_must_use)]
pub mod io; pub mod io;
pub mod sparql; pub mod sparql;

@ -1212,16 +1212,19 @@ impl StorageBulkLoader {
} }
} }
#[must_use]
pub fn set_num_threads(mut self, num_threads: usize) -> Self { pub fn set_num_threads(mut self, num_threads: usize) -> Self {
self.num_threads = Some(num_threads); self.num_threads = Some(num_threads);
self self
} }
#[must_use]
pub fn set_max_memory_size_in_megabytes(mut self, max_memory_size: usize) -> Self { pub fn set_max_memory_size_in_megabytes(mut self, max_memory_size: usize) -> Self {
self.max_memory_size = Some(max_memory_size); self.max_memory_size = Some(max_memory_size);
self self
} }
#[must_use]
pub fn on_progress(mut self, callback: impl Fn(u64) + 'static) -> Self { pub fn on_progress(mut self, callback: impl Fn(u64) + 'static) -> Self {
self.hooks.push(Box::new(callback)); self.hooks.push(Box::new(callback));
self self

@ -1390,6 +1390,7 @@ impl BulkLoader {
/// This number must be at last 2 (one for parsing and one for loading). /// This number must be at last 2 (one for parsing and one for loading).
/// ///
/// The default value is 2. /// The default value is 2.
#[must_use]
pub fn set_num_threads(mut self, num_threads: usize) -> Self { pub fn set_num_threads(mut self, num_threads: usize) -> Self {
self.storage = self.storage.set_num_threads(num_threads); self.storage = self.storage.set_num_threads(num_threads);
self self
@ -1404,6 +1405,7 @@ impl BulkLoader {
/// (for example if the data contains very long IRIs or literals). /// (for example if the data contains very long IRIs or literals).
/// ///
/// By default, a target 2GB per used thread is used. /// By default, a target 2GB per used thread is used.
#[must_use]
pub fn set_max_memory_size_in_megabytes(mut self, max_memory_size: usize) -> Self { pub fn set_max_memory_size_in_megabytes(mut self, max_memory_size: usize) -> Self {
self.storage = self self.storage = self
.storage .storage
@ -1412,6 +1414,7 @@ impl BulkLoader {
} }
/// Adds a `callback` evaluated from time to time with the number of loaded triples. /// Adds a `callback` evaluated from time to time with the number of loaded triples.
#[must_use]
pub fn on_progress(mut self, callback: impl Fn(u64) + 'static) -> Self { pub fn on_progress(mut self, callback: impl Fn(u64) + 'static) -> Self {
self.storage = self.storage.on_progress(callback); self.storage = self.storage.on_progress(callback);
self self
@ -1421,6 +1424,7 @@ impl BulkLoader {
/// by returning `Ok` or fail by returning `Err`. /// by returning `Ok` or fail by returning `Err`.
/// ///
/// By default the parsing fails. /// By default the parsing fails.
#[must_use]
pub fn on_parse_error( pub fn on_parse_error(
mut self, mut self,
callback: impl Fn(ParseError) -> Result<(), ParseError> + 'static, callback: impl Fn(ParseError) -> Result<(), ParseError> + 'static,

Loading…
Cancel
Save