Skip to content

ByteArrays

[Source]

class val ByteArrays is
  ValBytes val,
  Hashable ref

Implements


Constructors

create

[Source]

new val create(
  left': ValBytes val = reference,
  right': ValBytes val = reference)
: ByteArrays val^

Parameters

Returns


Public Functions

size

[Source]

fun box size()
: USize val

Returns


apply

[Source]

fun box apply(
  i: USize val)
: U8 val ?

Parameters

Returns

  • U8 val ?

values

[Source]

fun box values()
: Iterator[U8 val] ref

Returns


arrays

[Source]

Get the accumulated arrays represented by this instance inside an array.

fun val arrays()
: Array[Array[U8 val] val] iso^

Returns


drop

[Source]

fun val drop(
  amount: USize val)
: ByteArrays val

Parameters

Returns


take

[Source]

fun val take(
  amount: USize val)
: ByteArrays val

Parameters

Returns


select

[Source]

Get a ByteArrays instance to the selected range.

fun val select(
  from: USize val = 0,
  to: USize val = call)
: ByteArrays val

Parameters

Returns


trim

[Source]

Get the selected range as an array.

In best case no additional allocation, yay!

fun box trim(
  from: USize val = 0,
  to: USize val = call)
: Array[U8 val] val

Parameters

Returns


copy_to

[Source]

fun box copy_to(
  dst: Array[U8 val] ref,
  src_idx: USize val,
  dst_idx: USize val,
  len: USize val)
: None val

Parameters

Returns


string

[Source]

diverges from usual Stringable.string in that it can be used to get a substring of the whole ByteArrays instance and that the result is val and in best case no additional allocation was necessary.

fun box string(
  from: USize val = 0,
  to: USize val = call)
: String val

Parameters

Returns


array

[Source]

fun box array()
: Array[U8 val] val

Returns


add

[Source]

Enable convenient concatenation via + operator:

ByteArrays("a") + "b" + [as U8: 'c']
fun val add(
  other: (ValBytes val | String val))
: ByteArrays val

Parameters

Returns


left

[Source]

fun val left()
: ValBytes val

Returns


[Source]

fun val right()
: ValBytes val

Returns


debug

[Source]

fun val debug()
: String val

Returns


find

[Source]

Try to find sub in this ByteArrays.

If found, returns a tuple with the first element being true and the second element being the starting index of sub in this.

let ba = ByteArrays + "abc" + "def"
match ba.find("cd")
| (true, let cd_index: USize) => "found"
| (false, _) => "not found"
end
fun box find(
  sub: ReadSeq[U8 val] box,
  start: USize val = 0,
  stop: USize val = call)
: (Bool val , USize val)

Parameters

Returns


skip_while

[Source]

returns the first index for which f returns false, USize.max_value() if it never returns true

fun box skip_while(
  f: {(U8): Bool ?} val,
  start: USize val)
: USize val

Parameters

  • f: {(U8): Bool ?} val
  • start: USize val

Returns


skip

[Source]

return the first index in this that doesnt contain any element of skip_chars.

If we reach the end while skipping USize.max_value() is returned.

fun box skip(
  skip_chars: ReadSeq[U8 val] box,
  start: USize val = 0)
: USize val

Parameters

Returns


hash

[Source]

fun box hash()
: USize val

Returns


read_u8[optional T: U8 val]

[Source]

fun box read_u8[optional T: U8 val](
  offset: USize val)
: U8 val ?

Parameters

Returns

  • U8 val ?

read_u16[optional T: U8 val]

[Source]

fun box read_u16[optional T: U8 val](
  offset: USize val)
: U16 val ?

Parameters

Returns


read_u32[optional T: U8 val]

[Source]

fun box read_u32[optional T: U8 val](
  offset: USize val)
: U32 val ?

Parameters

Returns


read_u64[optional T: U8 val]

[Source]

fun box read_u64[optional T: U8 val](
  offset: USize val)
: U64 val ?

Parameters

Returns


read_u128[optional T: U8 val]

[Source]

fun box read_u128[optional T: U8 val](
  offset: USize val)
: U128 val ?

Parameters

Returns