File: cbor.rb

package info (click to toggle)
ruby-aws-sdk-core 3.212.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,232 kB
  • sloc: ruby: 17,533; makefile: 4
file content (53 lines) | stat: -rw-r--r-- 1,428 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true

require_relative 'cbor/encoder'
require_relative 'cbor/decoder'

module Aws
  # @api private
  module Cbor

    # CBOR Tagged data (Major type 6).
    # A Tag consists of a tag number and a value.
    # In the extended generic data model, a tag number's definition
    # describes the additional semantics conveyed with the tag number.
    # # @!method initialize(*args)
    #   @option args [Integer] :tag The tag number.
    #   @option args [Object] :value The tag's content.
    # @!attribute tag
    #   The tag number.
    #   @return [Integer]
    # @!attribute value
    #   The tag's content.
    #   @return [Object]
    Tagged = Struct.new(:tag, :value)

    class Error < StandardError; end

    class OutOfBytesError < Error
      def initialize(n, left)
        super("Out of bytes. Trying to read #{n} bytes but buffer contains only #{left}")
      end
    end

    class UnknownTypeError < Error
      def initialize(type)
        super("Unable to encode #{type}")
      end
    end

    class ExtraBytesError < Error
      def initialize(pos, size)
        super("Extra bytes follow after decoding item. Read #{pos} / #{size} bytes")
      end
    end

    class UnexpectedBreakCodeError < Error; end

    class UnexpectedAdditionalInformationError < Error
      def initialize(add_info)
        super("Unexpected additional information: #{add_info}")
      end
    end
  end
end