Skip to content

Bytes Slice

The bytes::slice function extracts a subset of a byte slice based on the specified start and end indices.

Syntax

bytes::slice(<byte-slice>, <start-index>, <end-index>)

Parameters

  • byte-slice: The input byte slice from which to extract a subset.
  • start-index: The starting index (inclusive).
  • end-index: The ending index (exclusive).

Returns

  • Byte Slice: A new byte slice containing the specified range of bytes.

Example

bytes::slice(response::body::bytes(), 1, 4)

Output

"ell"

This function is useful for extracting portions of binary data or strings.