std.string.Bytes
Bytes
A type that is a contiguous sequence of bytes.
This type is useful for methods that need to operate on a sequence of bytes
(e.g. by iterating over them), but don't care if the input is a String
or
ByteArray
.
Required methods
byte
Show source codeHide source code
fn pub byte(index: Int) -> Int
fn pub byte(index: Int) -> Int
Returns the byte at the given byte index.
Panics
If the index is out of bounds, this method panics.
bytes
Show source codeHide source code
fn pub bytes -> Iter[Int]
fn pub bytes -> Iter[Int]
Returns an iterator over the bytes in self
.
size
Show source codeHide source code
fn pub size -> Int
fn pub size -> Int
Returns the number of bytes in self
.
slice
Show source codeHide source code
fn pub slice(start: Int, size: Int) -> ByteArray
fn pub slice(start: Int, size: Int) -> ByteArray
Slices self
into a sub sequence of bytes, using a byte range.
to_pointer
Show source codeHide source code
fn pub to_pointer -> Pointer[UInt8]
fn pub to_pointer -> Pointer[UInt8]
Returns a raw pointer to the bytes of self
This method is meant for FFI purposes, and use of it should be avoided at all costs.
Implementations
ByteArray
impl Bytes for ByteArray
String
impl Bytes for String