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 standard library.
std › crypto › tls › Decoder › decode Public Function decode Doc Source Public Function std.crypto.tls.Decoder.decode
pub fn decode (d : *Decoder , comptime T : type ) T Params File crypto/tls.zig: 690
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718 pub fn decode (d : *Decoder , comptime T : type ) T {
switch (@typeInfo (T )) {
.int => |info | switch (info .bits ) {
8 => {
skip (d , 1 );
return d .buf [d .idx - 1 ];
},
16 => {
skip (d , 2 );
const b0 : u16 = d .buf [d .idx - 2 ];
const b1 : u16 = d .buf [d .idx - 1 ];
return (b0 << 8 ) | b1 ;
},
24 => {
skip (d , 3 );
const b0 : u24 = d .buf [d .idx - 3 ];
const b1 : u24 = d .buf [d .idx - 2 ];
const b2 : u24 = d .buf [d .idx - 1 ];
return (b0 << 16 ) | (b1 << 8 ) | b2 ;
},
else => @compileError ("unsupported int type: " ++ @typeName (T )),
},
.@"enum" => |info | {
if (info .mode == .exhaustive ) @compileError ("exhaustive enum cannot be used" );
return @fromBackingInt (@intCast (d .decode (info .tag_type )));
},
else => @compileError ("unsupported type: " ++ @typeName (T )),
}
}
Use this function to increase
idx.