Re: [PATCH net-next v3 2/8] rust: time: Introduce Delta type
From: FUJITA Tomonori
Date: Thu Oct 17 2024 - 07:16:40 EST
On Wed, 16 Oct 2024 10:23:49 +0200
Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
> On Wed, Oct 16, 2024 at 5:53 AM FUJITA Tomonori
> <fujita.tomonori@xxxxxxxxx> wrote:
>>
>> Introduce a type representing a span of time. Define our own type
>> because `core::time::Duration` is large and could panic during
>> creation.
>>
>> time::Ktime could be also used for time duration but timestamp and
>> timedelta are different so better to use a new type.
>>
>> i64 is used instead of u64 to represent a span of time; some C drivers
>> uses negative Deltas and i64 is more compatible with Ktime using i64
>> too (e.g., ktime_[us|ms]_delta() APIs return i64 so we create Delta
>> object without type conversion.
>
> Is there a reason that Delta wraps i64 directly instead of wrapping
> the Ktime type? I'd like to see the reason in the commit message.
You meant that bindings::ktime_t is used instead of i64 like:
pub struct Delta {
nanos: bindings::ktime_t,
}
? I've not considered but might make sense.