NAME

CBOR::Free::SequenceDecoder

SYNOPSIS

my $decoder = CBOR::Free::SequenceDecoder->new();

if ( my $got_sr = $decoder->give( $some_cbor ) ) {

    # Do something with your decoded CBOR.
}

while (my $got_sr = $decoder->get()) {
    # Do something with your decoded CBOR.
}

DESCRIPTION

This module implements a parser for CBOR Sequences (RFC 8742).

METHODS

This module implements the following methods in common with CBOR::Free::Decoder:

  • new()

  • preserve_references()

  • naive_utf8()

  • string_decode_cbor()

  • string_decode_never()

  • string_decode_always()

  • set_tag_handlers()

Additionally, the following exist:

$got_sr = CLASS->give( $CBOR );

Adds some bytes ($CBOR) to the decoder’s internal CBOR buffer. Returns either:

  • a scalar reference to the (parsed) first CBOR document in the internal buffer

  • undef, if there is no such document

Note that if your decoded CBOR document’s root element is already a reference (e.g., an array or hash reference), then the return value is a reference to that reference. So, for example, if you expect all documents in your stream to be array references, you could do:

if ( my $got_sr = $decoder->give( $some_cbor ) ) {
    my @decoded_array = @{ $$got_sr };

    # …
}

$got_sr = CLASS->get();

Like give() but doesn’t append onto the internal CBOR buffer.