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 › compress › lzma › Decompress › readIndirect Private Function readIndirect Doc Source Private Function std.compress.lzma.Decompress.readIndirect
fn readIndirect (r : *Reader ) Reader .Error !usize Params File compress/lzma.zig: 703
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755 fn readIndirect (r : *Reader ) Reader .Error !usize {
const d : *Decompress = @alignCast (@fieldParentPtr ("reader" , r ));
const gpa = d .gpa ;
var allocating = Writer .Allocating .initOwnedSlice (gpa , r .buffer );
allocating .writer .end = r .end ;
defer {
r .buffer = allocating .writer .buffer ;
r .end = allocating .writer .end ;
}
if (d .decode .state == math .maxInt (usize )) return error .EndOfStream ;
process_next : {
if (d .unpacked_size ) |unpacked_size | {
if (d .buffer .len >= unpacked_size ) break :process_next ;
} else if (d .range_decoder .isFinished ()) {
break :process_next ;
}
var n_read : u64 = 0 ;
switch (d .decode .process (d .input , &allocating , &d .buffer , &d .range_decoder , &n_read ) catch |err | switch (err ) {
error .WriteFailed => {
d .err = error .OutOfMemory ;
return error .ReadFailed ;
},
error .EndOfStream => {
d .err = error .EndOfStream ;
return error .ReadFailed ;
},
else => |e | {
d .err = e ;
return error .ReadFailed ;
},
}) {
.more => return 0 ,
.finished => break :process_next ,
}
}
if (d .unpacked_size ) |unpacked_size | {
if (d .buffer .len != unpacked_size ) {
d .err = error .DecompressedSizeMismatch ;
return error .ReadFailed ;
}
}
d .buffer .finish (&allocating .writer ) catch |err | switch (err ) {
error .WriteFailed => {
d .err = error .OutOfMemory ;
return error .ReadFailed ;
},
};
d .decode .state = math .maxInt (usize );
return 0 ;
}