| 1 | //! OID encoder with `const` support. |
| 2 | |
| 3 | use craterust-analyzer cargo const-oid 0.10.2 crate/::{ |
| 4 | Arcrust-analyzer cargo const-oid 0.10.2 arcs/Arc#, Bufferrust-analyzer cargo const-oid 0.10.2 buffer/Buffer#, Errorrust-analyzer cargo const-oid 0.10.2 error/Error#, ObjectIdentifierrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier#, Resultrust-analyzer cargo const-oid 0.10.2 error/Result#, |
| 5 | arcsrust-analyzer cargo const-oid 0.10.2 arcs/::{ARC_MAX_FIRSTrust-analyzer cargo const-oid 0.10.2 arcs/ARC_MAX_FIRST., ARC_MAX_SECONDrust-analyzer cargo const-oid 0.10.2 arcs/ARC_MAX_SECOND.}, |
| 6 | }; |
| 7 | |
| 8 | /// BER/DER encoder. |
| 9 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 10 | pub(craterust-analyzer cargo const-oid 0.10.2 crate/) struct Encoderrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#<const MAX_SIZE: usize> { |
| 11 | /// Current state. |
| 12 | staterust-analyzer cargo const-oid 0.10.2 encoder/Encoder#state.: Staterust-analyzer cargo const-oid 0.10.2 encoder/State#, |
| 13 | |
| 14 | /// Bytes of the OID being BER-encoded in-progress. |
| 15 | bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes.: [u8; MAX_SIZE], |
| 16 | |
| 17 | /// Current position within the byte buffer. |
| 18 | cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor.: usize, |
| 19 | } |
| 20 | |
| 21 | /// Current state of the encoder. |
| 22 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 23 | enum Staterust-analyzer cargo const-oid 0.10.2 encoder/State# { |
| 24 | /// Initial state - no arcs yet encoded. |
| 25 | Initialrust-analyzer cargo const-oid 0.10.2 encoder/State#Initial#, |
| 26 | |
| 27 | /// First arc has been supplied and stored as the wrapped [`Arc`]. |
| 28 | FirstArcrust-analyzer cargo const-oid 0.10.2 encoder/State#FirstArc#(Arcrust-analyzer cargo const-oid 0.10.2 arcs/Arc#), |
| 29 | |
| 30 | /// Encoding base 128 body of the OID. |
| 31 | Bodyrust-analyzer cargo const-oid 0.10.2 encoder/State#Body#, |
| 32 | } |
| 33 | |
| 34 | impl<const MAX_SIZE: usize> Encoderrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#<MAX_SIZE> { |
| 35 | /// Create a new encoder initialized to an empty default state. |
| 36 | pub(craterust-analyzer cargo const-oid 0.10.2 crate/) const fn newrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]new().() -> Selfrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`] { |
| 37 | Selfrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`] { |
| 38 | staterust-analyzer cargo const-oid 0.10.2 encoder/Encoder#state.: Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::Initialrust-analyzer cargo const-oid 0.10.2 encoder/State#Initial#, |
| 39 | bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes.: [0u8; MAX_SIZE], |
| 40 | cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor.: 0, |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /// Extend an existing OID. |
| 45 | pub(craterust-analyzer cargo const-oid 0.10.2 crate/) const fn extendrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]extend().(oid: ObjectIdentifierrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier#<MAX_SIZE>) -> Selfrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`] { |
| 46 | Selfrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`] { |
| 47 | staterust-analyzer cargo const-oid 0.10.2 encoder/Encoder#state.: Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::Bodyrust-analyzer cargo const-oid 0.10.2 encoder/State#Body#, |
| 48 | bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes.: oid.berrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier#ber..bytesrust-analyzer cargo const-oid 0.10.2 buffer/Buffer#bytes., |
| 49 | cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor.: oid.berrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier#ber..lengthrust-analyzer cargo const-oid 0.10.2 buffer/Buffer#length. as usize, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /// Encode an [`Arc`] as base 128 into the internal buffer. |
| 54 | pub(craterust-analyzer cargo const-oid 0.10.2 crate/) const fn arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(mut self, arc: Arcrust-analyzer cargo const-oid 0.10.2 arcs/Arc#) -> Resultrust-analyzer cargo const-oid 0.10.2 error/Result#<Selfrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]> { |
| 55 | match self.staterust-analyzer cargo const-oid 0.10.2 encoder/Encoder#state. { |
| 56 | Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::Initialrust-analyzer cargo const-oid 0.10.2 encoder/State#Initial# => { |
| 57 | if arc rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().ARC_MAX_FIRSTrust-analyzer cargo const-oid 0.10.2 arcs/ARC_MAX_FIRST. { |
| 58 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const-oid 0.10.2 error/Error#::ArcInvalidrust-analyzer cargo const-oid 0.10.2 error/Error#ArcInvalid# { arcrust-analyzer cargo const-oid 0.10.2 error/Error#ArcInvalid#arc. }); |
| 59 | } |
| 60 | |
| 61 | self.staterust-analyzer cargo const-oid 0.10.2 encoder/Encoder#state. = Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::FirstArcrust-analyzer cargo const-oid 0.10.2 encoder/State#FirstArc#(arc); |
| 62 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self) |
| 63 | } |
| 64 | Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::FirstArcrust-analyzer cargo const-oid 0.10.2 encoder/State#FirstArc#(first_arc) => { |
| 65 | if arc rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().ARC_MAX_SECONDrust-analyzer cargo const-oid 0.10.2 arcs/ARC_MAX_SECOND. { |
| 66 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const-oid 0.10.2 error/Error#::ArcInvalidrust-analyzer cargo const-oid 0.10.2 error/Error#ArcInvalid# { arcrust-analyzer cargo const-oid 0.10.2 error/Error#ArcInvalid#arc. }); |
| 67 | } |
| 68 | |
| 69 | self.staterust-analyzer cargo const-oid 0.10.2 encoder/Encoder#state. = Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::Bodyrust-analyzer cargo const-oid 0.10.2 encoder/State#Body#; |
| 70 | self.bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = checked_addrust-analyzer cargo const-oid 0.10.2 checked/checked_add!!( |
| 71 | checked_mulrust-analyzer cargo const-oid 0.10.2 checked/checked_mul!!(checked_addrust-analyzer cargo const-oid 0.10.2 checked/checked_add!!(ARC_MAX_SECONDrust-analyzer cargo const-oid 0.10.2 arcs/ARC_MAX_SECOND., 1), first_arc), |
| 72 | arc |
| 73 | ) as u8; |
| 74 | self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor. = 1; |
| 75 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self) |
| 76 | } |
| 77 | Staterust-analyzer cargo const-oid 0.10.2 encoder/State#::Bodyrust-analyzer cargo const-oid 0.10.2 encoder/State#Body# => self.encode_base128rust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]encode_base128().(arc), |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /// Finish encoding an OID. |
| 82 | pub(craterust-analyzer cargo const-oid 0.10.2 crate/) const fn finishrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]finish().(self) -> Resultrust-analyzer cargo const-oid 0.10.2 error/Result#<ObjectIdentifierrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier#<MAX_SIZE>> { |
| 83 | if self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 84 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const-oid 0.10.2 error/Error#::Emptyrust-analyzer cargo const-oid 0.10.2 error/Error#Empty#); |
| 85 | } |
| 86 | |
| 87 | let ber = Bufferrust-analyzer cargo const-oid 0.10.2 buffer/Buffer# { |
| 88 | bytesrust-analyzer cargo const-oid 0.10.2 buffer/Buffer#bytes.: self.bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes., |
| 89 | lengthrust-analyzer cargo const-oid 0.10.2 buffer/Buffer#length.: self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor. as u8, |
| 90 | }; |
| 91 | |
| 92 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ObjectIdentifierrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier# { berrust-analyzer cargo const-oid 0.10.2 ObjectIdentifier#ber. }) |
| 93 | } |
| 94 | |
| 95 | /// Encode base 128. |
| 96 | const fn encode_base128rust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]encode_base128().(mut self, arc: Arcrust-analyzer cargo const-oid 0.10.2 arcs/Arc#) -> Resultrust-analyzer cargo const-oid 0.10.2 error/Result#<Selfrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]> { |
| 97 | let nbytes = base128_lenrust-analyzer cargo const-oid 0.10.2 encoder/base128_len().(arc); |
| 98 | let end_pos = checked_addrust-analyzer cargo const-oid 0.10.2 checked/checked_add!!(self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor., nbytes); |
| 99 | |
| 100 | if end_pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().MAX_SIZE { |
| 101 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const-oid 0.10.2 error/Error#::Lengthrust-analyzer cargo const-oid 0.10.2 error/Error#Length#); |
| 102 | } |
| 103 | |
| 104 | let mut i = 0; |
| 105 | while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().nbytes { |
| 106 | // TODO(tarcieri): use `?` when stable in `const fn` |
| 107 | self.bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = match base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(arc, i, nbytes) { |
| 108 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(byte) => byte, |
| 109 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e), |
| 110 | }; |
| 111 | self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor. = checked_addrust-analyzer cargo const-oid 0.10.2 checked/checked_add!!(self.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor., 1); |
| 112 | i = checked_addrust-analyzer cargo const-oid 0.10.2 checked/checked_add!!(i, 1); |
| 113 | } |
| 114 | |
| 115 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /// Compute the length of an arc when encoded in base 128. |
| 120 | const fn base128_lenrust-analyzer cargo const-oid 0.10.2 encoder/base128_len().(arc: Arcrust-analyzer cargo const-oid 0.10.2 arcs/Arc#) -> usize { |
| 121 | match arc { |
| 122 | 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x7f => 1, // up to 7 bits |
| 123 | 0x80..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x3fff => 2, // up to 14 bits |
| 124 | 0x4000..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x1fffff => 3, // up to 21 bits |
| 125 | 0x200000..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x0fffffff => 4, // up to 28 bits |
| 126 | _ => 5, |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /// Compute the big endian base 128 encoding of the given [`Arc`] at the given byte. |
| 131 | const fn base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(arc: Arcrust-analyzer cargo const-oid 0.10.2 arcs/Arc#, pos: usize, total: usize) -> Resultrust-analyzer cargo const-oid 0.10.2 error/Result#<u8> { |
| 132 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(pos <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). total); |
| 133 | let last_byte = checked_addrust-analyzer cargo const-oid 0.10.2 checked/checked_add!!(pos, 1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().total; |
| 134 | let mask = if last_byte { 0 } else { 0b10000000 }; |
| 135 | let shift = checked_mulrust-analyzer cargo const-oid 0.10.2 checked/checked_mul!!(checked_subrust-analyzer cargo const-oid 0.10.2 checked/checked_sub!!(checked_subrust-analyzer cargo const-oid 0.10.2 checked/checked_sub!!(total, pos), 1), 7); |
| 136 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(((arc rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<usize>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<usize>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<usize>`]shr().shift) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0b1111111) as u8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().mask) |
| 137 | } |
| 138 | |
| 139 | #[cfg(test)] |
| 140 | #[allow(clippy::unwrap_used)] |
| 141 | mod testsrust-analyzer cargo const-oid 0.10.2 encoder/tests/ { |
| 142 | use superrust-analyzer cargo const-oid 0.10.2 encoder/::Encoderrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#; |
| 143 | use hex_literalrust-analyzer cargo hex-literal 1.1.0 crate/::hexrust-analyzer cargo hex-literal 1.1.0 hex!; |
| 144 | |
| 145 | /// OID `1.2.840.10045.2.1` encoded as ASN.1 BER/DER |
| 146 | const EXAMPLE_OID_BERrust-analyzer cargo const-oid 0.10.2 encoder/tests/EXAMPLE_OID_BER.: &[u8] = &hexrust-analyzer cargo hex-literal 1.1.0 hex!!("2A8648CE3D0201"); |
| 147 | |
| 148 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 149 | fn base128_byterust-analyzer cargo const-oid 0.10.2 encoder/tests/base128_byte().() { |
| 150 | let example_arc = 0x44332211; |
| 151 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo const-oid 0.10.2 encoder/::base128_lenrust-analyzer cargo const-oid 0.10.2 encoder/base128_len().(example_arc), 5); |
| 152 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo const-oid 0.10.2 encoder/::base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(example_arc, 0, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0b10000100); |
| 153 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo const-oid 0.10.2 encoder/::base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(example_arc, 1, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0b10100001); |
| 154 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo const-oid 0.10.2 encoder/::base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(example_arc, 2, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0b11001100); |
| 155 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo const-oid 0.10.2 encoder/::base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(example_arc, 3, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0b11000100); |
| 156 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo const-oid 0.10.2 encoder/::base128_byterust-analyzer cargo const-oid 0.10.2 encoder/base128_byte().(example_arc, 4, 5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0b10001); |
| 157 | } |
| 158 | |
| 159 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 160 | fn encoderust-analyzer cargo const-oid 0.10.2 encoder/tests/encode().() { |
| 161 | let encoder = Encoderrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#::<7>::newrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]new().(); |
| 162 | let encoder = encoder.arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 163 | let encoder = encoder.arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 164 | let encoder = encoder.arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(840).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 165 | let encoder = encoder.arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(10045).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 166 | let encoder = encoder.arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 167 | let encoder = encoder.arcrust-analyzer cargo const-oid 0.10.2 encoder/impl#[`Encoder<MAX_SIZE>`]arc().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 168 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&encoder.bytesrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...encoder.cursorrust-analyzer cargo const-oid 0.10.2 encoder/Encoder#cursor.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., EXAMPLE_OID_BERrust-analyzer cargo const-oid 0.10.2 encoder/tests/EXAMPLE_OID_BER.); |
| 169 | } |
| 170 | } |