Documentation

Init.Data.ByteArray.Basic

structure ByteArray :
Instances For
    @[extern lean_mk_empty_byte_array]
    Equations
    @[extern lean_byte_array_push]
    Equations
    @[extern lean_byte_array_size]
    Equations
    @[extern lean_byte_array_uget]
    Equations
    @[extern lean_byte_array_get]
    Equations
    @[extern lean_byte_array_fget]
    Equations
    @[extern lean_byte_array_set]
    Equations
    @[extern lean_byte_array_fset]
    Equations
    @[extern lean_byte_array_uset]
    Equations
    @[extern lean_byte_array_hash]
    @[extern lean_byte_array_copy_slice]
    def ByteArray.copySlice (src : ByteArray) (srcOff : Nat) (dest : ByteArray) (destOff : Nat) (len : Nat) (exact : optParam Bool true) :

    Copy the slice at [srcOff, srcOff + len) in src to [destOff, destOff + len) in dest, growing dest if necessary. If exact is false, the capacity will be doubled when grown.

    Equations
    • One or more equations did not get rendered due to their size.
    partial def ByteArray.toList.loop (bs : ByteArray) (i : Nat) (r : List UInt8) :
    @[inline]
    def ByteArray.findIdx? (a : ByteArray) (p : UInt8Bool) (start : optParam Nat 0) :
    Equations
    @[specialize #[]]
    partial def ByteArray.findIdx?.loop (a : ByteArray) (p : UInt8Bool) (i : Nat) :
    @[inline]
    unsafe def ByteArray.forInUnsafe {β : Type v} {m : Type v → Type w} [inst : Monad m] (as : ByteArray) (b : β) (f : UInt8βm (ForInStep β)) :
    m β

    We claim this unsafe implementation is correct because an array cannot have more than usizeSz elements in our runtime. This is similar to the Array version.

    TODO: avoid code duplication in the future after we improve the compiler.

    Equations
    @[specialize #[]]
    unsafe def ByteArray.forInUnsafe.loop {β : Type v} {m : Type v → Type w} [inst : Monad m] (as : ByteArray) (f : UInt8βm (ForInStep β)) (sz : USize) (i : USize) (b : β) :
    m β
    Equations
    • One or more equations did not get rendered due to their size.
    @[implemented_by ByteArray.forInUnsafe]
    def ByteArray.forIn {β : Type v} {m : Type v → Type w} [inst : Monad m] (as : ByteArray) (b : β) (f : UInt8βm (ForInStep β)) :
    m β

    Reference implementation for forIn

    Equations
    def ByteArray.forIn.loop {β : Type v} {m : Type v → Type w} [inst : Monad m] (as : ByteArray) (f : UInt8βm (ForInStep β)) (i : Nat) (h : i ByteArray.size as) (b : β) :
    m β
    Equations
    Equations
    • ByteArray.instForInByteArrayUInt8 = { forIn := fun {β} [Monad m] => ByteArray.forIn }
    @[inline]
    unsafe def ByteArray.foldlMUnsafe {β : Type v} {m : Type v → Type w} [inst : Monad m] (f : βUInt8m β) (init : β) (as : ByteArray) (start : optParam Nat 0) (stop : optParam Nat (ByteArray.size as)) :
    m β

    See comment at forInUnsafe

    Equations
    • One or more equations did not get rendered due to their size.
    @[specialize #[]]
    unsafe def ByteArray.foldlMUnsafe.fold {β : Type v} {m : Type v → Type w} [inst : Monad m] (f : βUInt8m β) (as : ByteArray) (i : USize) (stop : USize) (b : β) :
    m β
    Equations
    • One or more equations did not get rendered due to their size.
    @[implemented_by ByteArray.foldlMUnsafe]
    def ByteArray.foldlM {β : Type v} {m : Type v → Type w} [inst : Monad m] (f : βUInt8m β) (init : β) (as : ByteArray) (start : optParam Nat 0) (stop : optParam Nat (ByteArray.size as)) :
    m β

    Reference implementation for foldlM

    Equations
    • One or more equations did not get rendered due to their size.
    def ByteArray.foldlM.loop {β : Type v} {m : Type v → Type w} [inst : Monad m] (f : βUInt8m β) (as : ByteArray) (stop : Nat) (h : stop ByteArray.size as) (i : Nat) (j : Nat) (b : β) :
    m β
    Equations
    • One or more equations did not get rendered due to their size.
    @[inline]
    def ByteArray.foldl {β : Type v} (f : βUInt8β) (init : β) (as : ByteArray) (start : optParam Nat 0) (stop : optParam Nat (ByteArray.size as)) :
    β
    Equations

    Interpret a ByteArray of size 8 as a little-endian UInt64.

    Equations
    • One or more equations did not get rendered due to their size.

    Interpret a ByteArray of size 8 as a big-endian UInt64.

    Equations
    • One or more equations did not get rendered due to their size.