ciborium 0.1.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/NOTICE.md +26 -0
- data/README.md +221 -0
- data/Rakefile +46 -0
- data/ext/ciborium/Cargo.lock +339 -0
- data/ext/ciborium/Cargo.toml +26 -0
- data/ext/ciborium/build.rs +4 -0
- data/ext/ciborium/extconf.rb +8 -0
- data/ext/ciborium/src/canonical.rs +60 -0
- data/ext/ciborium/src/cursor.rs +106 -0
- data/ext/ciborium/src/decode.rs +325 -0
- data/ext/ciborium/src/encode.rs +330 -0
- data/ext/ciborium/src/error.rs +53 -0
- data/ext/ciborium/src/lib.rs +153 -0
- data/ext/ciborium/src/scan.rs +223 -0
- data/lib/ciborium/compat/buffer.rb +190 -0
- data/lib/ciborium/compat/errors.rb +30 -0
- data/lib/ciborium/compat/packer.rb +90 -0
- data/lib/ciborium/compat/unpacker.rb +111 -0
- data/lib/ciborium/compat.rb +110 -0
- data/lib/ciborium/decode_options.rb +61 -0
- data/lib/ciborium/decoder.rb +141 -0
- data/lib/ciborium/encode_options.rb +41 -0
- data/lib/ciborium/encoded.rb +10 -0
- data/lib/ciborium/encoder.rb +80 -0
- data/lib/ciborium/errors.rb +25 -0
- data/lib/ciborium/extensions/bignum.rb +35 -0
- data/lib/ciborium/extensions/regexp.rb +41 -0
- data/lib/ciborium/extensions/time.rb +39 -0
- data/lib/ciborium/extensions/uri.rb +29 -0
- data/lib/ciborium/extensions.rb +92 -0
- data/lib/ciborium/native.rb +25 -0
- data/lib/ciborium/replace.rb +105 -0
- data/lib/ciborium/simple.rb +21 -0
- data/lib/ciborium/tagged.rb +18 -0
- data/lib/ciborium/version.rb +6 -0
- data/lib/ciborium.rb +65 -0
- data/sig/generated/ciborium/compat/buffer.rbs +95 -0
- data/sig/generated/ciborium/compat/errors.rbs +23 -0
- data/sig/generated/ciborium/compat/packer.rbs +53 -0
- data/sig/generated/ciborium/compat/unpacker.rbs +59 -0
- data/sig/generated/ciborium/compat.rbs +57 -0
- data/sig/generated/ciborium/decode_options.rbs +41 -0
- data/sig/generated/ciborium/decoder.rbs +85 -0
- data/sig/generated/ciborium/encode_options.rbs +33 -0
- data/sig/generated/ciborium/encoded.rbs +16 -0
- data/sig/generated/ciborium/encoder.rbs +50 -0
- data/sig/generated/ciborium/errors.rbs +32 -0
- data/sig/generated/ciborium/extensions/bignum.rbs +20 -0
- data/sig/generated/ciborium/extensions/regexp.rbs +30 -0
- data/sig/generated/ciborium/extensions/time.rbs +22 -0
- data/sig/generated/ciborium/extensions/uri.rbs +20 -0
- data/sig/generated/ciborium/extensions.rbs +35 -0
- data/sig/generated/ciborium/native.rbs +10 -0
- data/sig/generated/ciborium/replace.rbs +37 -0
- data/sig/generated/ciborium/version.rbs +5 -0
- data/sig/generated/ciborium.rbs +30 -0
- data/sig/manual/ciborium/extensions.rbs +12 -0
- data/sig/manual/ciborium/native.rbs +23 -0
- data/sig/manual/ciborium/tagged.rbs +25 -0
- metadata +123 -0
|
@@ -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,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
|
metadata
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ciborium
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sorah Fukumori
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rb_sys
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.9.130
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.9.130
|
|
26
|
+
description: A CBOR implementation backed by a Rust extension. Tags carry no meaning
|
|
27
|
+
unless an extension for them is allowlisted. Ships a compatibility layer for the
|
|
28
|
+
cbor gem's interface.
|
|
29
|
+
email:
|
|
30
|
+
- sorah@ivry.jp
|
|
31
|
+
executables: []
|
|
32
|
+
extensions:
|
|
33
|
+
- ext/ciborium/extconf.rb
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- CHANGELOG.md
|
|
37
|
+
- LICENSE.txt
|
|
38
|
+
- NOTICE.md
|
|
39
|
+
- README.md
|
|
40
|
+
- Rakefile
|
|
41
|
+
- ext/ciborium/Cargo.lock
|
|
42
|
+
- ext/ciborium/Cargo.toml
|
|
43
|
+
- ext/ciborium/build.rs
|
|
44
|
+
- ext/ciborium/extconf.rb
|
|
45
|
+
- ext/ciborium/src/canonical.rs
|
|
46
|
+
- ext/ciborium/src/cursor.rs
|
|
47
|
+
- ext/ciborium/src/decode.rs
|
|
48
|
+
- ext/ciborium/src/encode.rs
|
|
49
|
+
- ext/ciborium/src/error.rs
|
|
50
|
+
- ext/ciborium/src/lib.rs
|
|
51
|
+
- ext/ciborium/src/scan.rs
|
|
52
|
+
- lib/ciborium.rb
|
|
53
|
+
- lib/ciborium/compat.rb
|
|
54
|
+
- lib/ciborium/compat/buffer.rb
|
|
55
|
+
- lib/ciborium/compat/errors.rb
|
|
56
|
+
- lib/ciborium/compat/packer.rb
|
|
57
|
+
- lib/ciborium/compat/unpacker.rb
|
|
58
|
+
- lib/ciborium/decode_options.rb
|
|
59
|
+
- lib/ciborium/decoder.rb
|
|
60
|
+
- lib/ciborium/encode_options.rb
|
|
61
|
+
- lib/ciborium/encoded.rb
|
|
62
|
+
- lib/ciborium/encoder.rb
|
|
63
|
+
- lib/ciborium/errors.rb
|
|
64
|
+
- lib/ciborium/extensions.rb
|
|
65
|
+
- lib/ciborium/extensions/bignum.rb
|
|
66
|
+
- lib/ciborium/extensions/regexp.rb
|
|
67
|
+
- lib/ciborium/extensions/time.rb
|
|
68
|
+
- lib/ciborium/extensions/uri.rb
|
|
69
|
+
- lib/ciborium/native.rb
|
|
70
|
+
- lib/ciborium/replace.rb
|
|
71
|
+
- lib/ciborium/simple.rb
|
|
72
|
+
- lib/ciborium/tagged.rb
|
|
73
|
+
- lib/ciborium/version.rb
|
|
74
|
+
- sig/generated/ciborium.rbs
|
|
75
|
+
- sig/generated/ciborium/compat.rbs
|
|
76
|
+
- sig/generated/ciborium/compat/buffer.rbs
|
|
77
|
+
- sig/generated/ciborium/compat/errors.rbs
|
|
78
|
+
- sig/generated/ciborium/compat/packer.rbs
|
|
79
|
+
- sig/generated/ciborium/compat/unpacker.rbs
|
|
80
|
+
- sig/generated/ciborium/decode_options.rbs
|
|
81
|
+
- sig/generated/ciborium/decoder.rbs
|
|
82
|
+
- sig/generated/ciborium/encode_options.rbs
|
|
83
|
+
- sig/generated/ciborium/encoded.rbs
|
|
84
|
+
- sig/generated/ciborium/encoder.rbs
|
|
85
|
+
- sig/generated/ciborium/errors.rbs
|
|
86
|
+
- sig/generated/ciborium/extensions.rbs
|
|
87
|
+
- sig/generated/ciborium/extensions/bignum.rbs
|
|
88
|
+
- sig/generated/ciborium/extensions/regexp.rbs
|
|
89
|
+
- sig/generated/ciborium/extensions/time.rbs
|
|
90
|
+
- sig/generated/ciborium/extensions/uri.rbs
|
|
91
|
+
- sig/generated/ciborium/native.rbs
|
|
92
|
+
- sig/generated/ciborium/replace.rbs
|
|
93
|
+
- sig/generated/ciborium/version.rbs
|
|
94
|
+
- sig/manual/ciborium/extensions.rbs
|
|
95
|
+
- sig/manual/ciborium/native.rbs
|
|
96
|
+
- sig/manual/ciborium/tagged.rbs
|
|
97
|
+
homepage: https://github.com/sorah/ciborium-ruby
|
|
98
|
+
licenses:
|
|
99
|
+
- MIT
|
|
100
|
+
metadata:
|
|
101
|
+
allowed_push_host: https://rubygems.org
|
|
102
|
+
homepage_uri: https://github.com/sorah/ciborium-ruby
|
|
103
|
+
source_code_uri: https://github.com/sorah/ciborium-ruby
|
|
104
|
+
changelog_uri: https://github.com/sorah/ciborium-ruby/blob/main/CHANGELOG.md
|
|
105
|
+
rubygems_mfa_required: 'true'
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: 3.3.0
|
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
requirements: []
|
|
120
|
+
rubygems_version: 4.0.20
|
|
121
|
+
specification_version: 4
|
|
122
|
+
summary: Memory-safe CBOR (RFC 8949) encoder and decoder with allowlisted tag extensions
|
|
123
|
+
test_files: []
|