Module bytes

Source
Description

Bytes — contiguous byte sequence.

Bytes is a newtype over (Vec Byte) with its own dispatch identity; every method lives directly on :impl Bytes.

Seq-hierarchy impls (Foldable, Mappable, Filterable, Chainable, Zippable) and Concat arrive alongside the wider Seq wiring.

Data Types

Types

Int

Trait Implementations

impl Bytes

.concat ( Bytes Bytes Bytes )

Append b to a (same as .chain in the spec).

.from-base64 ( Str (Result Bytes Str) )

(Bytes .from-base64) — decode a RFC 4648 standard Base64 string into Bytes. Qualified dispatch: "aGVsbG8=" (Bytes .from-base64).

.from-be-bytes ( Bytes (Int ..) )

Decode a big-endian integer from the bytes. Length MUST be 1, 2, 4, or 8.

.from-hex ( Str (Result Bytes Str) )

(Bytes .from-hex) — decode a lowercase-or-uppercase hex string into Bytes. Returns Err with a message on odd length or non-hex characters. Qualified dispatch: "cafe" (Bytes .from-hex).

.from-le-bytes ( Bytes (Int ..) )

Decode a little-endian integer from the bytes. Length MUST be 1, 2, 4, or 8.

.from-str ( Str Bytes )

(Bytes .from-str)StrBytes. Always succeeds because every Str is valid UTF-8, and valid UTF-8 is a valid byte sequence. Qualified dispatch: "abc" (Bytes .from-str).

.get ( (Int ..) Bytes (Option (Int 0..)) )

Byte at index (0-based) as (Option AnyUInt); None if out of bounds.

.is-empty ( Bytes Bool )

True iff the sequence has zero bytes.

.len ( Bytes (Int ..) )

Number of bytes in the sequence. O(1).

.slice ( (Int ..) (Int ..) Bytes Bytes )

Half-open slice [start, end) as a new Bytes. Out-of-range or inverted bounds yield an empty Bytes.

.to-base64 ( Bytes Str )

Standard Base64 (RFC 4648) with = padding.

.to-hex ( Bytes Str )

Lowercase hex (two chars per byte) — always valid ASCII.

.to-str ( Bytes (Result Str Str) )

Validate as UTF-8 and return Ok str / Err message.

impl Int for ?520301

.to-be-bytes ( (Int range) Bytes )

.to-be-bytes — encode an integer as an 8-byte big-endian sequence (Rust's i64::to_be_bytes). Dispatches on the integer's type.

.to-le-bytes ( (Int range) Bytes )

.to-le-bytes — encode an integer as an 8-byte little-endian sequence (Rust's i64::to_le_bytes).