union Timeout [src]

Fields

none
ms: u16

Members

Source

pub const Timeout = union(enum) { none, ms: u16, pub fn to_i32_ms(t: Timeout) i32 { return switch (t) { .none => -1, .ms => |ms| ms, }; } pub fn toTimespec(t: Timeout, buf: *std.posix.timespec) ?*std.posix.timespec { return switch (t) { .none => null, .ms => |ms_u16| { const ms: isize = ms_u16; buf.* = .{ .sec = @divTrunc(ms, std.time.ms_per_s), .nsec = @rem(ms, std.time.ms_per_s) * std.time.ns_per_ms, }; return buf; }, }; } }