File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
6
6
## [ Unreleased] - ReleaseDate
7
7
### Added
8
8
9
+ - Added const constructors for ` TimeSpec ` and ` TimeVal `
10
+ (#[ 1760] ( https://github.com/nix-rust/nix/pull/1760 ) )
9
11
- Added ` aio_writev ` and ` aio_readv ` .
10
12
(#[ 1713] ( https://github.com/nix-rust/nix/pull/1713 ) )
11
-
12
13
- impl ` From<uid_t> ` for ` Uid ` and ` From<gid_t> ` for ` Gid `
13
14
(#[ 1727] ( https://github.com/nix-rust/nix/pull/1727 ) )
14
15
- impl From<SockaddrIn > for std::net::SocketAddrV4 and
Original file line number Diff line number Diff line change @@ -330,6 +330,14 @@ impl TimeValLike for TimeSpec {
330
330
}
331
331
332
332
impl TimeSpec {
333
+ /// Construct a new `TimeSpec` from its components
334
+ pub const fn new ( seconds : time_t , nanoseconds : timespec_tv_nsec_t ) -> Self {
335
+ Self ( timespec {
336
+ tv_sec : seconds,
337
+ tv_nsec : nanoseconds,
338
+ } )
339
+ }
340
+
333
341
fn nanos_mod_sec ( & self ) -> timespec_tv_nsec_t {
334
342
if self . tv_sec ( ) < 0 && self . tv_nsec ( ) > 0 {
335
343
self . tv_nsec ( ) - NANOS_PER_SEC as timespec_tv_nsec_t
@@ -564,6 +572,14 @@ impl TimeValLike for TimeVal {
564
572
}
565
573
566
574
impl TimeVal {
575
+ /// Construct a new `TimeVal` from its components
576
+ pub const fn new ( seconds : time_t , microseconds : suseconds_t ) -> Self {
577
+ Self ( timeval {
578
+ tv_sec : seconds,
579
+ tv_usec : microseconds,
580
+ } )
581
+ }
582
+
567
583
fn micros_mod_sec ( & self ) -> suseconds_t {
568
584
if self . tv_sec ( ) < 0 && self . tv_usec ( ) > 0 {
569
585
self . tv_usec ( ) - MICROS_PER_SEC as suseconds_t
You can’t perform that action at this time.
0 commit comments