Explorer

cbor.decode

description
Read bytes that are exactly one CBOR data item (none if it is not CBOR this project reads, or if bytes are left after it)
type
Fn(bytes: List<Number>) -> Union{#none, #some(@cbor.item)}
expression
fn(bytes$0) =>
  match @cbor.read(bytes: $0, offset: 0) {
    #some(read$1) =>
      match @core.equal(left: $1.next, right: @core.list-length(value: $0)) {
        true =>
          #some($1.value),
        false =>
          #none
      },
    #none(_) =>
      #none
  }
visibility
public
cbor.decode (project cbor, branch main, snapshot 5bvML2Im-osGmgnKJsp0FwmfSMONephnrgdWQboV3-E)
id: TY3N1ZicGZVtTZx0KHAa0J5nUyz6hxD8tXjAMbU-nKo
content hash: GVVyjOMDTxwQ9N7aSN4KfLl9unYVqSIRydDuD8-zXhI