menu
ByteBuffer
import { ByteBuffer } from "destack:bytes";
Growable byte buffer.
1export class ByteBuffer {2 storage: Unique<[MaybeUninit<uint8>]>;3 initializedLength: isize;4 allocatedCapacity: usize;5 static new(): ^ByteBuffer;6 static withCapacity(capacity: usize): ^ByteBuffer;7 static from(bytes: &'a readonly [uint8]): ^ByteBuffer;8 get length(): isize;9 get size(): isize;10 get capacity(): usize;11 get isEmpty(): boolean;12 reserve(additional: usize): void;13 clear(): void;14 compact(): void;15 writeByte(value: uint8): void;16 write(bytes: &'b readonly [uint8]): void;17 fill(value: uint8, count: isize): void;18 asBytes<const A: Access = "readonly">(): WithAccess<&[uint8], A>;19 toBytes(): readonly [uint8];20 intoBytes(): readonly [uint8];21}Members
storage: Unique<[MaybeUninit<uint8>]>The owned byte storage.
initializedLength: isizeThe initialized byte count.
allocatedCapacity: usizeThe allocated byte capacity.
static new(): ^ByteBufferCreate an empty byte buffer.
static withCapacity(capacity: usize): ^ByteBufferCreate a byte buffer with room for at least
capacitybytes.static from(bytes: &'a readonly [uint8]): ^ByteBufferCreate a byte buffer containing
bytes.get length(): isizeReturn the initialized byte count.
get size(): isizeReturn the initialized byte count.
get capacity(): usizeReturn the allocated byte capacity.
get isEmpty(): booleanReturn whether this buffer has no initialized bytes.
reserve(additional: usize): voidReserve room for at least
additionalmore bytes.clear(): voidRemove all initialized bytes.
compact(): voidRelease unused capacity.
writeByte(value: uint8): voidAppend one byte.
write(bytes: &'b readonly [uint8]): voidAppend bytes.
fill(value: uint8, count: isize): voidAppend
countcopies ofvalue.asBytes<const A: Access = "readonly">(): WithAccess<&[uint8], A>Borrow initialized bytes.
toBytes(): readonly [uint8]Clone initialized bytes into immutable storage.
intoBytes(): readonly [uint8]Move initialized bytes into immutable storage.