bytes
Byte buffers are Vec<byte>. Offsets are byte offsets, and nothing here knows about UTF-8; use text for strings. A string literal can be passed where a Vec<byte> is expected.
Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.
Import what you use (use path::* is not allowed):
use bytes::{Bytes, region_eq};
Types#
Functions#
| Name | Description |
|---|---|
region_eq | True when a[ao..ao+n) equals b[bo..bo+n) (caller guarantees bounds). |
to_hex | Encodes buf as lowercase hexadecimal, two digits per byte. |
from_hex | Decodes hexadecimal text (either case) into bytes. |
slice | Returns a copy of src[start..end] (end exclusive), with both offsets clamped to the buffer. |
concat | Returns a new buffer holding a followed by b. |
eq | Returns true when a and b have the same length and the same bytes. |
find_from | Returns the offset of the first needle in hay at or after start, or -1. |
find | Returns the offset of the first needle in hay, or -1. |
rfind | Returns the offset of the last needle in hay, or -1. |
contains | Returns true when needle occurs in hay. |
starts_with | Returns true when buf begins with prefix. |
ends_with | Returns true when buf ends with suffix. |
copy | Returns a new buffer with the same bytes as src. |
replace | Returns a copy of hay with every non-overlapping old replaced by new, left to right. |
repeat | Returns src repeated n times (empty when n <= 0). |
pad_left | Returns src with fill bytes added in front until it is width long; a longer src is returned unchanged. |
pad_right | Returns src with fill bytes added at the end until it is width long; a longer src is returned unchanged. |
to_string | Decodes b as UTF-8. |
from_string | Returns the UTF-8 bytes of s; the same as string::to_bytes. |