Module ggstd::bytes

source ·
Expand description

Package bytes implements functions for the manipulation of byte slices. It is analogous to the facilities of the strings package.

Structs

  • A Buffer is a variable-sized buffer of bytes with read and write methods.
  • A Reader implements the crate::io::Reader, crate::io::ReaderAt, crate::io::WriterTo, crate::io::Seeker, crate::io::ByteScanner, and io.RuneScanner interfaces by reading from a u8 slice. Unlike a Buffer, a Reader is read-only and supports seeking. The zero value for Reader operates like a Reader of an empty slice.

Functions

  • equal reports whether a and b are the same length and contain the same bytes.
  • has_suffix tests whether the byte slice s ends with suffix.
  • index_byte returns the index of the first instance of c in b, or -1 if c is not present in b.
  • new_buffer creates and initializes a new Buffer using buf as its initial contents. The new Buffer takes ownership of buf, and the caller should not use buf after this call. new_buffer is intended to prepare a Buffer to read existing data. It can also be used to set the initial size of the internal buffer for writing. To do that, buf should have the desired capacity but a length of zero.
  • new_buffer_string creates and initializes a new Buffer using string s as its initial contents. It is intended to prepare a buffer to read an existing string.
  • repeat returns a new byte slice consisting of count copies of b.