ciborium 0.1.0-x86_64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE.txt +21 -0
  4. data/NOTICE.md +26 -0
  5. data/README.md +221 -0
  6. data/Rakefile +46 -0
  7. data/lib/ciborium/3.3/ciborium_native.so +0 -0
  8. data/lib/ciborium/3.4/ciborium_native.so +0 -0
  9. data/lib/ciborium/4.0/ciborium_native.so +0 -0
  10. data/lib/ciborium/compat/buffer.rb +190 -0
  11. data/lib/ciborium/compat/errors.rb +30 -0
  12. data/lib/ciborium/compat/packer.rb +90 -0
  13. data/lib/ciborium/compat/unpacker.rb +111 -0
  14. data/lib/ciborium/compat.rb +110 -0
  15. data/lib/ciborium/decode_options.rb +61 -0
  16. data/lib/ciborium/decoder.rb +141 -0
  17. data/lib/ciborium/encode_options.rb +41 -0
  18. data/lib/ciborium/encoded.rb +10 -0
  19. data/lib/ciborium/encoder.rb +80 -0
  20. data/lib/ciborium/errors.rb +25 -0
  21. data/lib/ciborium/extensions/bignum.rb +35 -0
  22. data/lib/ciborium/extensions/regexp.rb +41 -0
  23. data/lib/ciborium/extensions/time.rb +39 -0
  24. data/lib/ciborium/extensions/uri.rb +29 -0
  25. data/lib/ciborium/extensions.rb +92 -0
  26. data/lib/ciborium/native.rb +25 -0
  27. data/lib/ciborium/replace.rb +105 -0
  28. data/lib/ciborium/simple.rb +21 -0
  29. data/lib/ciborium/tagged.rb +18 -0
  30. data/lib/ciborium/version.rb +6 -0
  31. data/lib/ciborium.rb +65 -0
  32. data/licenses/cfg-if-LICENSE-APACHE +201 -0
  33. data/licenses/cfg-if-LICENSE-MIT +25 -0
  34. data/licenses/ciborium-io-LICENSE +201 -0
  35. data/licenses/ciborium-ll-LICENSE +201 -0
  36. data/licenses/half-LICENSE-APACHE +176 -0
  37. data/licenses/half-LICENSE-MIT +19 -0
  38. data/licenses/magnus-LICENSE +21 -0
  39. data/licenses/rb-sys-LICENSE-APACHE +190 -0
  40. data/licenses/rb-sys-LICENSE-MIT +21 -0
  41. data/licenses/zerocopy-LICENSE-APACHE +202 -0
  42. data/licenses/zerocopy-LICENSE-BSD +24 -0
  43. data/licenses/zerocopy-LICENSE-MIT +26 -0
  44. data/sig/generated/ciborium/compat/buffer.rbs +95 -0
  45. data/sig/generated/ciborium/compat/errors.rbs +23 -0
  46. data/sig/generated/ciborium/compat/packer.rbs +53 -0
  47. data/sig/generated/ciborium/compat/unpacker.rbs +59 -0
  48. data/sig/generated/ciborium/compat.rbs +57 -0
  49. data/sig/generated/ciborium/decode_options.rbs +41 -0
  50. data/sig/generated/ciborium/decoder.rbs +85 -0
  51. data/sig/generated/ciborium/encode_options.rbs +33 -0
  52. data/sig/generated/ciborium/encoded.rbs +16 -0
  53. data/sig/generated/ciborium/encoder.rbs +50 -0
  54. data/sig/generated/ciborium/errors.rbs +32 -0
  55. data/sig/generated/ciborium/extensions/bignum.rbs +20 -0
  56. data/sig/generated/ciborium/extensions/regexp.rbs +30 -0
  57. data/sig/generated/ciborium/extensions/time.rbs +22 -0
  58. data/sig/generated/ciborium/extensions/uri.rbs +20 -0
  59. data/sig/generated/ciborium/extensions.rbs +35 -0
  60. data/sig/generated/ciborium/native.rbs +10 -0
  61. data/sig/generated/ciborium/replace.rbs +37 -0
  62. data/sig/generated/ciborium/version.rbs +5 -0
  63. data/sig/generated/ciborium.rbs +30 -0
  64. data/sig/manual/ciborium/extensions.rbs +12 -0
  65. data/sig/manual/ciborium/native.rbs +23 -0
  66. data/sig/manual/ciborium/tagged.rbs +25 -0
  67. metadata +115 -0
@@ -0,0 +1,59 @@
1
+ # Generated from lib/ciborium/compat/unpacker.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Compat
5
+ # CBOR::Unpacker of the cbor gem, reading through Ciborium::Decoder. Input passes through
6
+ # buffer, which also reads from io when more is needed.
7
+ class Unpacker
8
+ @buffer: Buffer
9
+
10
+ @decoder: Ciborium::Decoder
11
+
12
+ attr_reader buffer: Buffer
13
+
14
+ # options takes symbolize_keys, and the Buffer options.
15
+ #
16
+ # : (?untyped io, ?Hash[Symbol, untyped]? options) -> void
17
+ def initialize: (?untyped io, ?Hash[Symbol, untyped]? options) -> void
18
+
19
+ # : (String data) -> self
20
+ def feed: (String data) -> self
21
+
22
+ # : () -> untyped
23
+ def read: () -> untyped
24
+
25
+ # : () -> nil
26
+ def skip: () -> nil
27
+
28
+ # Whether the next item is null. Consumes nothing.
29
+ #
30
+ # : () -> bool
31
+ def skip_nil: () -> bool
32
+
33
+ # : () -> Integer
34
+ def read_array_header: () -> Integer
35
+
36
+ # : () -> Integer
37
+ def read_map_header: () -> Integer
38
+
39
+ # Yields each item until the input runs out, leaving a partial item buffered.
40
+ #
41
+ # : () { (untyped) -> void } -> nil
42
+ # : () -> Enumerator[untyped, nil]
43
+ def each: () { (untyped) -> void } -> nil
44
+ | () -> Enumerator[untyped, nil]
45
+
46
+ # : (String data) { (untyped) -> void } -> nil
47
+ def feed_each: (String data) { (untyped) -> void } -> nil
48
+
49
+ # : () -> nil
50
+ def reset: () -> nil
51
+
52
+ # Runs the block on the decoder, moving more input into it until the block stops raising
53
+ # IncompleteError or the input ends.
54
+ #
55
+ # : [T] () { () -> T } -> T
56
+ private def with_input: [T] () { () -> T } -> T
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,57 @@
1
+ # Generated from lib/ciborium/compat.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ # The interface of the cbor gem (CBOR), implemented on top of Ciborium. Tag extensions follow
5
+ # Compat.extensions, so a tag that is not allowlisted decodes to Tagged. require
6
+ # "ciborium/replace" to install it as CBOR.
7
+ module Compat
8
+ Tagged: untyped
9
+
10
+ Simple: untyped
11
+
12
+ # Nothing is allowlisted until the application opts in, as with Ciborium itself.
13
+ DEFAULT_EXTENSIONS: Array[extension]
14
+
15
+ self.@extensions: Array[extension]
16
+
17
+ # The extensions every Compat entry point uses, process-wide.
18
+ #
19
+ # : () -> Array[extension]
20
+ def self.extensions: () -> Array[extension]
21
+
22
+ # : (Array[extension] extensions) -> void
23
+ def self.extensions=: (Array[extension] extensions) -> void
24
+
25
+ # Options for Ciborium::Encoder that reproduce the cbor gem's encoding.
26
+ #
27
+ # : () -> Hash[Symbol, untyped]
28
+ def self.encode_options: () -> Hash[Symbol, untyped]
29
+
30
+ # Options for Ciborium::Decoder that reproduce the cbor gem's decoding.
31
+ #
32
+ # : () -> Hash[Symbol, untyped]
33
+ def self.decode_options: () -> Hash[Symbol, untyped]
34
+
35
+ # Encodes object, or writes it to io and returns nil when io is given.
36
+ #
37
+ # : (untyped object, ?untyped io) -> String?
38
+ def self.encode: (untyped object, ?untyped io) -> String?
39
+
40
+ # Decodes a single item from a String, or from all that an IO holds.
41
+ #
42
+ # options is {symbolize_keys: true}, or :keys_as_symbols.
43
+ #
44
+ # : (untyped source, ?(Hash[Symbol, untyped] | Symbol)? options) -> untyped
45
+ def self.decode: (untyped source, ?(Hash[Symbol, untyped] | Symbol)? options) -> untyped
46
+
47
+ # Encodes an object Ciborium cannot represent through its own to_cbor(packer), as the cbor
48
+ # gem does.
49
+ FALLBACK: ^(untyped) -> untyped
50
+
51
+ # to_cbor for the classes the cbor gem extends. Installed by ciborium/replace.
52
+ module CoreExt
53
+ # : (?untyped packer_or_io) -> untyped
54
+ def to_cbor: (?untyped packer_or_io) -> untyped
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,41 @@
1
+ # Generated from lib/ciborium/decode_options.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ DEFAULT_MAX_DEPTH: Integer
5
+
6
+ MAX_DEPTH_LIMIT: Integer
7
+
8
+ # Encoding rules a profile enforces beyond well-formedness. :ctap2 is the CTAP2 canonical CBOR
9
+ # encoding form that WebAuthn requires: no tags, no indefinite lengths, arguments in their
10
+ # shortest form, and map keys ordered without duplicates.
11
+ PROFILES: Array[Symbol]
12
+
13
+ # Decoding options, validated and packed into the arguments the native decoder takes.
14
+ class DecodeOptions < Data
15
+ attr_reader max_depth(): Integer
16
+
17
+ attr_reader flags(): Integer
18
+
19
+ attr_reader handlers(): Hash[Integer, ^(Integer, untyped) -> untyped]?
20
+
21
+ def self.new: (Integer max_depth, Integer flags, Hash[Integer, ^(Integer, untyped) -> untyped]? handlers) -> instance
22
+ | (max_depth: Integer, flags: Integer, handlers: Hash[Integer, ^(Integer, untyped) -> untyped]?) -> instance
23
+
24
+ def self.members: () -> [ :max_depth, :flags, :handlers ]
25
+
26
+ def members: () -> [ :max_depth, :flags, :handlers ]
27
+ end
28
+
29
+ class DecodeOptions
30
+ # extensions lists the allowlisted extensions (see Extensions); every other tag decodes to
31
+ # Tagged. profile rejects input that breaks one of PROFILES.
32
+ #
33
+ # : (?extensions: Array[extension], ?symbolize_keys: bool, ?max_depth: Integer, ?duplicate_keys: Symbol, ?profile: Symbol?) -> DecodeOptions
34
+ def self.build: (?extensions: Array[extension], ?symbolize_keys: bool, ?max_depth: Integer, ?duplicate_keys: Symbol, ?profile: Symbol?) -> DecodeOptions
35
+
36
+ # Returns whether profile is :ctap2.
37
+ #
38
+ # : (Symbol? profile, untyped extensions) -> bool
39
+ def self.check_profile: (Symbol? profile, untyped extensions) -> bool
40
+ end
41
+ end
@@ -0,0 +1,85 @@
1
+ # Generated from lib/ciborium/decoder.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ # Decodes data items from input that arrives in parts. Nothing is consumed until a whole item
5
+ # has arrived, so reads that raise IncompleteError can be retried after feeding more.
6
+ class Decoder
7
+ include Enumerable[untyped]
8
+
9
+ # Consumed bytes are dropped from the buffer once they exceed this size.
10
+ COMPACT_THRESHOLD: Integer
11
+
12
+ @scan_state: Native::ScanState
13
+
14
+ @pos: Integer
15
+
16
+ @buffer: String
17
+
18
+ @options: DecodeOptions
19
+
20
+ # Options are those of DecodeOptions.build.
21
+ #
22
+ # : (**untyped options) -> void
23
+ def initialize: (**untyped options) -> void
24
+
25
+ # : (String bytes) -> self
26
+ def feed: (String bytes) -> self
27
+
28
+ # Decodes the next item. Raises IncompleteError when it has not fully arrived.
29
+ #
30
+ # : () -> untyped
31
+ def read: () -> untyped
32
+
33
+ # Yields each item that has fully arrived, leaving a partial one buffered.
34
+ #
35
+ # : () { (untyped) -> void } -> self
36
+ # : () -> Enumerator[untyped, self]
37
+ def each: () { (untyped) -> void } -> self
38
+ | () -> Enumerator[untyped, self]
39
+
40
+ # Skips the next item without decoding it.
41
+ #
42
+ # : () -> self
43
+ def skip: () -> self
44
+
45
+ # Reads the head of a definite-length array and returns its length, leaving the elements to
46
+ # be read one by one.
47
+ #
48
+ # : () -> Integer
49
+ def read_array_header: () -> Integer
50
+
51
+ # Reads the head of a definite-length map and returns its number of pairs.
52
+ #
53
+ # : () -> Integer
54
+ def read_map_header: () -> Integer
55
+
56
+ # Whether the next item is null. Consumes nothing.
57
+ #
58
+ # : () -> bool
59
+ def next_nil?: () -> bool
60
+
61
+ # : () -> Integer
62
+ def buffered_bytes: () -> Integer
63
+
64
+ # Drops all buffered input.
65
+ #
66
+ # : () -> self
67
+ def reset: () -> self
68
+
69
+ # : () -> Integer
70
+ private def item_end: () -> Integer
71
+
72
+ # Moves to the next item, whose scan starts afresh.
73
+ #
74
+ # : (Integer pos) -> void
75
+ private def advance: (Integer pos) -> void
76
+
77
+ # : (Integer major, String name) -> Integer
78
+ private def read_container_head: (Integer major, String name) -> Integer
79
+
80
+ # The scan state is relative to @pos, so it stays valid.
81
+ #
82
+ # : () -> void
83
+ private def compact: () -> void
84
+ end
85
+ end
@@ -0,0 +1,33 @@
1
+ # Generated from lib/ciborium/encode_options.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ # Encoding options, validated into the arguments the native encoder takes.
5
+ class EncodeOptions < Data
6
+ attr_reader max_depth(): Integer
7
+
8
+ attr_reader flags(): Integer
9
+
10
+ attr_reader fallback(): Proc?
11
+
12
+ attr_reader class_handlers(): Array[[ Module, ^(untyped) -> untyped ]]?
13
+
14
+ def self.new: (Integer max_depth, Integer flags, Proc? fallback, Array[[ Module, ^(untyped) -> untyped ]]? class_handlers) -> instance
15
+ | (max_depth: Integer, flags: Integer, fallback: Proc?, class_handlers: Array[[ Module, ^(untyped) -> untyped ]]?) -> instance
16
+
17
+ def self.members: () -> [ :max_depth, :flags, :fallback, :class_handlers ]
18
+
19
+ def members: () -> [ :max_depth, :flags, :fallback, :class_handlers ]
20
+ end
21
+
22
+ class EncodeOptions
23
+ # extensions lists the allowlisted extensions (see Extensions). fallback is called with each
24
+ # object neither the encoder nor an extension can represent, and returns an object to encode
25
+ # in its place. profile makes the output follow one of PROFILES, sorting map keys.
26
+ #
27
+ # : (?extensions: Array[extension], ?max_depth: Integer, ?fallback: (^(untyped) -> untyped)?, ?profile: Symbol?) -> EncodeOptions
28
+ def self.build: (?extensions: Array[extension], ?max_depth: Integer, ?fallback: (^(untyped) -> untyped)?, ?profile: Symbol?) -> EncodeOptions
29
+
30
+ # : (^(untyped) -> untyped fallback) -> Proc
31
+ def self.wrap_fallback: (^(untyped) -> untyped fallback) -> Proc
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ # Generated from lib/ciborium/encoded.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ # A data item that is already encoded, written out as-is by the encoder. The encoder checks
5
+ # that bytes hold exactly one well-formed item.
6
+ class Encoded < Data
7
+ attr_reader bytes(): String
8
+
9
+ def self.new: (String bytes) -> instance
10
+ | (bytes: String) -> instance
11
+
12
+ def self.members: () -> [ :bytes ]
13
+
14
+ def members: () -> [ :bytes ]
15
+ end
16
+ end
@@ -0,0 +1,50 @@
1
+ # Generated from lib/ciborium/encoder.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ # Writes data items one after another into a buffer, for output built in parts.
5
+ class Encoder
6
+ @options: EncodeOptions
7
+
8
+ @buffer: String
9
+
10
+ # Options are those of EncodeOptions.build.
11
+ #
12
+ # : (**untyped options) -> void
13
+ def initialize: (**untyped options) -> void
14
+
15
+ # : (untyped object) -> self
16
+ def write: (untyped object) -> self
17
+
18
+ # Writes the head of an array whose length items the caller writes next.
19
+ #
20
+ # : (Integer length) -> self
21
+ def write_array_header: (Integer length) -> self
22
+
23
+ # Writes the head of a map whose length key-value pairs the caller writes next.
24
+ #
25
+ # : (Integer length) -> self
26
+ def write_map_header: (Integer length) -> self
27
+
28
+ # Writes a tag head; the caller writes the tag content next.
29
+ #
30
+ # : (Integer tag) -> self
31
+ def write_tag: (Integer tag) -> self
32
+
33
+ # A copy of everything written so far.
34
+ #
35
+ # : () -> String
36
+ def bytes: () -> String
37
+
38
+ # : () -> Integer
39
+ def size: () -> Integer
40
+
41
+ # : () -> bool
42
+ def empty?: () -> bool
43
+
44
+ # : () -> self
45
+ def clear: () -> self
46
+
47
+ # : (Integer major, Integer argument) -> self
48
+ private def write_head: (Integer major, Integer argument) -> self
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ # Generated from lib/ciborium/errors.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ class Error < StandardError
5
+ end
6
+
7
+ class DecodeError < Error
8
+ end
9
+
10
+ # The input is not well-formed CBOR, or breaks a rule the decoder enforces.
11
+ class MalformedError < DecodeError
12
+ end
13
+
14
+ # The input ends in the middle of a data item.
15
+ class IncompleteError < DecodeError
16
+ end
17
+
18
+ # Containers and tags are nested deeper than max_depth.
19
+ class DepthError < DecodeError
20
+ end
21
+
22
+ # An allowlisted extension failed to decode a tag's content. The cause holds the original error.
23
+ class ExtensionError < DecodeError
24
+ end
25
+
26
+ # A Decoder head reader found an item of another type.
27
+ class UnexpectedTypeError < DecodeError
28
+ end
29
+
30
+ class EncodeError < Error
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ # Generated from lib/ciborium/extensions/bignum.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Extensions
5
+ # Tags 2 and 3 (RFC 8949 section 3.4.3): integers outside -2**64..2**64-1 as byte strings.
6
+ class BigInteger
7
+ # : () -> Array[Integer]
8
+ def tags: () -> Array[Integer]
9
+
10
+ # : () -> Array[Module]
11
+ def classes: () -> Array[Module]
12
+
13
+ # : (Integer tag, untyped value) -> Integer
14
+ def decode: (Integer tag, untyped value) -> Integer
15
+
16
+ # : (Integer object) -> Tagged
17
+ def encode: (Integer object) -> Tagged
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ # Generated from lib/ciborium/extensions/regexp.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Extensions
5
+ # Tag 35 as Regexp. Compiling a pattern from untrusted input risks ReDoS, so pass a timeout
6
+ # unless Regexp.timeout is set.
7
+ class Regexp
8
+ FLAGS: Integer
9
+
10
+ @timeout: Float?
11
+
12
+ # : (?timeout: Float?) -> void
13
+ def initialize: (?timeout: Float?) -> void
14
+
15
+ # : () -> Array[Integer]
16
+ def tags: () -> Array[Integer]
17
+
18
+ # : () -> Array[Module]
19
+ def classes: () -> Array[Module]
20
+
21
+ # : (Integer tag, untyped value) -> ::Regexp
22
+ def decode: (Integer tag, untyped value) -> ::Regexp
23
+
24
+ # Tag 35 has no place for flags, so a Regexp with any is refused rather than changed.
25
+ #
26
+ # : (::Regexp object) -> Tagged
27
+ def encode: (::Regexp object) -> Tagged
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # Generated from lib/ciborium/extensions/time.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Extensions
5
+ # Tag 0 (RFC 3339 text) and tag 1 (seconds since the epoch) as Time.
6
+ class Time
7
+ # : () -> Array[Integer]
8
+ def tags: () -> Array[Integer]
9
+
10
+ # : () -> Array[Module]
11
+ def classes: () -> Array[Module]
12
+
13
+ # : (Integer tag, untyped value) -> ::Time
14
+ def decode: (Integer tag, untyped value) -> ::Time
15
+
16
+ # Whole seconds are written as an Integer, anything finer as a Float.
17
+ #
18
+ # : (::Time object) -> Tagged
19
+ def encode: (::Time object) -> Tagged
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ # Generated from lib/ciborium/extensions/uri.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Extensions
5
+ # Tag 32 (RFC 8949 section 3.4.5.3) as URI.
6
+ class URI
7
+ # : () -> Array[Integer]
8
+ def tags: () -> Array[Integer]
9
+
10
+ # : () -> Array[Module]
11
+ def classes: () -> Array[Module]
12
+
13
+ # : (Integer tag, untyped value) -> ::URI::Generic
14
+ def decode: (Integer tag, untyped value) -> ::URI::Generic
15
+
16
+ # : (::URI::Generic object) -> Tagged
17
+ def encode: (::URI::Generic object) -> Tagged
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,35 @@
1
+ # Generated from lib/ciborium/extensions.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ # Tag handling beyond Tagged, enabled per call through the extensions: option.
5
+ #
6
+ # An extension is any object that responds to:
7
+ #
8
+ # - tags: the tag numbers it decodes
9
+ # - classes: the classes whose instances it encodes
10
+ # - decode(tag, value): the object for a tag's decoded content
11
+ # - encode(object): an object to encode in place of object, typically a Tagged
12
+ #
13
+ # Symbols name the built-in extensions.
14
+ module Extensions
15
+ BUILTIN: Hash[Symbol, String]
16
+
17
+ # Resolves Symbols to the built-in extensions and checks every entry is an extension.
18
+ #
19
+ # : (untyped extensions) -> Array[_Extension]
20
+ def self.resolve: (untyped extensions) -> Array[_Extension]
21
+
22
+ # Maps each tag to a callable that wraps the extension's failures in ExtensionError.
23
+ #
24
+ # : (Array[_Extension] extensions) -> Hash[Integer, ^(Integer, untyped) -> untyped]?
25
+ def self.tag_handlers: (Array[_Extension] extensions) -> Hash[Integer, ^(Integer, untyped) -> untyped]?
26
+
27
+ # Pairs each class with a callable that wraps the extension's failures in EncodeError.
28
+ #
29
+ # : (Array[_Extension] extensions) -> Array[[Module, ^(untyped) -> untyped]]?
30
+ def self.class_handlers: (Array[_Extension] extensions) -> Array[[ Module, ^(untyped) -> untyped ]]?
31
+
32
+ # : (Symbol name) -> _Extension
33
+ def self.builtin: (Symbol name) -> _Extension
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ # Generated from lib/ciborium/native.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Native
5
+ # Called by the encoder for text in an encoding other than UTF-8 or US-ASCII.
6
+ #
7
+ # : (String string) -> String
8
+ def self.transcode: (String string) -> String
9
+ end
10
+ end
@@ -0,0 +1,37 @@
1
+ # Generated from lib/ciborium/replace.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ module Compat
5
+ # Classes the cbor gem gives to_cbor. URI::Generic is included when URI is loaded.
6
+ CORE_EXT_CLASSES: Array[Module]
7
+
8
+ # Constants of the cbor gem that CBOR carries.
9
+ CBOR_CONSTANTS: Array[Symbol]
10
+
11
+ # Module functions of the cbor gem that CBOR carries.
12
+ CBOR_FUNCTIONS: Array[Symbol]
13
+
14
+ self.@facade: Module?
15
+
16
+ # The frozen module installed as CBOR. It delegates to Compat rather than being Compat, so the
17
+ # cbor gem's extension, should it load anyway, fails on reopening it instead of replacing
18
+ # Compat's methods with its own.
19
+ #
20
+ # : () -> Module
21
+ def self.facade: () -> Module
22
+
23
+ # Marks every file of the installed cbor gems that require "cbor" could load as loaded.
24
+ #
25
+ # : () -> void
26
+ def self.block_cbor_gem: () -> void
27
+
28
+ # The cbor gem's entry point and extension: as found on the load path, and in every
29
+ # installed version, since RubyGems may activate any of them later.
30
+ #
31
+ # : () -> Array[String]
32
+ def self.cbor_gem_features: () -> Array[String]
33
+
34
+ # : () -> void
35
+ def self.install: () -> void
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # Generated from lib/ciborium/version.rb with RBS::Inline
2
+
3
+ module Ciborium
4
+ VERSION: String
5
+ end
@@ -0,0 +1,30 @@
1
+ # Generated from lib/ciborium.rb with RBS::Inline
2
+
3
+ # A CBOR (RFC 8949) encoder and decoder. Tags carry no meaning unless an extension for them is
4
+ # allowlisted.
5
+ module Ciborium
6
+ # Encodes object into a binary String.
7
+ #
8
+ # Options are those of EncodeOptions.build.
9
+ #
10
+ # : (untyped object, **untyped options) -> String
11
+ def self.encode: (untyped object, **untyped options) -> String
12
+
13
+ # Decodes a single data item. Raises MalformedError when bytes follow it.
14
+ #
15
+ # Options are those of DecodeOptions.build.
16
+ #
17
+ # : (String bytes, **untyped options) -> untyped
18
+ def self.decode: (String bytes, **untyped options) -> untyped
19
+
20
+ # Decodes the data item at the start of bytes and returns it with the number of bytes it took,
21
+ # leaving whatever follows unread.
22
+ #
23
+ # : (String bytes, **untyped options) -> [untyped, Integer]
24
+ def self.decode_prefix: (String bytes, **untyped options) -> [ untyped, Integer ]
25
+
26
+ # Decodes a CBOR sequence (RFC 8742), a concatenation of zero or more data items.
27
+ #
28
+ # : (String bytes, **untyped options) -> Array[untyped]
29
+ def self.decode_sequence: (String bytes, **untyped options) -> Array[untyped]
30
+ end
@@ -0,0 +1,12 @@
1
+ # Hand-written because rbs-inline cannot declare interfaces or type aliases.
2
+ module Ciborium
3
+ interface _Extension
4
+ def tags: () -> Array[Integer]
5
+ def classes: () -> Array[Module]
6
+ def decode: (Integer tag, untyped value) -> untyped
7
+ def encode: (untyped object) -> untyped
8
+ def inspect: () -> String
9
+ end
10
+
11
+ type extension = Symbol | _Extension
12
+ end
@@ -0,0 +1,23 @@
1
+ # Defined by the Rust extension under ext/ciborium, which rbs-inline cannot read.
2
+ module Ciborium
3
+ module Native
4
+ FLAG_SYMBOLIZE_KEYS: Integer
5
+ FLAG_LAST_WINS: Integer
6
+ FLAG_CTAP2: Integer
7
+
8
+ def self.decode: (String input, Integer offset, Integer max_depth, Integer flags, Hash[Integer, ^(Integer, untyped) -> untyped]? handlers) -> [untyped, Integer]
9
+
10
+ def self.encode: (untyped value, Integer max_depth, Integer flags, Proc? fallback, Array[[Module, ^(untyped) -> untyped]]? class_handlers) -> String
11
+
12
+ def self.scan: (String input, Integer offset, Integer max_depth, ScanState state) -> Integer?
13
+
14
+ # Progress of scanning one incomplete item, carried between scans.
15
+ class ScanState
16
+ def clear: () -> void
17
+ end
18
+
19
+ def self.read_head: (String input, Integer offset) -> [Integer, Integer?, Integer]?
20
+
21
+ def self.encode_head: (Integer major, Integer argument) -> String
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # Hand-written because Tagged and Simple override the Data constructor to validate.
2
+ module Ciborium
3
+ class Tagged < Data
4
+ MAX_TAG: Integer
5
+
6
+ attr_reader tag: Integer
7
+ attr_reader value: untyped
8
+
9
+ def self.new: (Integer tag, untyped value) -> Tagged
10
+ | (tag: Integer, value: untyped) -> Tagged
11
+
12
+ def initialize: (tag: Integer, value: untyped) -> void
13
+ end
14
+
15
+ class Simple < Data
16
+ attr_reader value: Integer
17
+
18
+ def self.new: (Integer value) -> Simple
19
+ | (value: Integer) -> Simple
20
+
21
+ def initialize: (value: Integer) -> void
22
+ end
23
+
24
+ UNDEFINED: Simple
25
+ end