Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › net.zig › Interface
Interface
net.Interface
pub const Interface = struct
File
Code
pub const Interface = struct {
index : u32 ,
pub const none : Interface = .{ .index = 0 };
pub const Name = struct {
bytes : [max_len :0 ]u8 ,
pub const max_len = if (@TypeOf (std .posix .IFNAMESIZE ) == void ) 0 else std .posix .IFNAMESIZE - 1 ;
pub fn toSlice (n : *const Name ) []const u8 {
return std .mem .sliceTo (&n .bytes , 0 );
}
pub fn fromSlice (bytes : []const u8 ) error {NameTooLong }!Name {
if (bytes .len > max_len ) return error .NameTooLong ;
return .fromSliceUnchecked (bytes );
}
pub fn fromSliceUnchecked (bytes : []const u8 ) Name {
assert (bytes .len <= max_len );
var result : Name = undefined ;
@memcpy (result .bytes [0 ..bytes .len ], bytes );
result .bytes [bytes .len ] = 0 ;
return result ;
}
pub const ResolveError = error {
InterfaceNotFound ,
AccessDenied ,
SystemResources ,
} || Io .UnexpectedError || Io .Cancelable ;
pub fn resolve (n : *const Name , io : Io ) ResolveError !Interface {
return io .vtable .netInterfaceNameResolve (io .userdata , n );
}
};
pub const NameError = error {
InterfaceNotFound ,
NameTooLong ,
} || Io .UnexpectedError || Io .Cancelable ;
pub fn name (i : Interface , io : Io ) NameError !Name {
assert (i .index != 0 );
return io .vtable .netInterfaceName (io .userdata , i );
}
pub fn isNone (i : Interface ) bool {
return i .index == 0 ;
}
}