| 1 | //! Serialize a Rust data structure to CBOR data. |
| 2 | |
| 3 | #[cfg(feature = "alloc")] |
| 4 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#; |
| 5 | |
| 6 | #[cfg(feature = "std")] |
| 7 | pub use craterust-analyzer cargo serde_cbor_2 0.13.0 crate/::writerust-analyzer cargo serde_cbor_2 0.13.0 write/::IoWriterust-analyzer cargo serde_cbor_2 0.13.0 write/IoWrite#; |
| 8 | pub use craterust-analyzer cargo serde_cbor_2 0.13.0 crate/::writerust-analyzer cargo serde_cbor_2 0.13.0 write/::{SliceWriterust-analyzer cargo serde_cbor_2 0.13.0 write/SliceWrite#, Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#}; |
| 9 | |
| 10 | use craterust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::{Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#, Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#}; |
| 11 | use halfrust-analyzer cargo half 2.6.0 crate/::f16rust-analyzer cargo half 2.6.0 binary16/f16#; |
| 12 | use serderust-analyzer cargo serde 1.0.144 crate/::serrust-analyzer cargo serde 1.0.144 ser/::{selfrust-analyzer cargo serde 1.0.144 ser/, Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#}; |
| 13 | #[cfg(feature = "std")] |
| 14 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 15 | |
| 16 | use craterust-analyzer cargo serde_cbor_2 0.13.0 crate/::tagsrust-analyzer cargo serde_cbor_2 0.13.0 tags/::{get_tagrust-analyzer cargo serde_cbor_2 0.13.0 tags/get_tag()., CBOR_NEWTYPE_NAMErust-analyzer cargo serde_cbor_2 0.13.0 tags/CBOR_NEWTYPE_NAME.}; |
| 17 | |
| 18 | /// Serializes a value to a vector. |
| 19 | #[cfg(any(feature = "std", feature = "alloc"))] |
| 20 | pub fn to_vecrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec().<T>(value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> |
| 21 | where |
| 22 | T: serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 23 | { |
| 24 | let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 25 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#::newrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]new().(&mut vec))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(vec) |
| 27 | } |
| 28 | |
| 29 | /// Serializes a value to a vector in packed format. |
| 30 | #[cfg(feature = "std")] |
| 31 | pub fn to_vec_packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec_packed().<T>(value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> |
| 32 | where |
| 33 | T: serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 34 | { |
| 35 | let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 36 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#::newrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]new().(&mut IoWriterust-analyzer cargo serde_cbor_2 0.13.0 write/IoWrite#::newrust-analyzer cargo serde_cbor_2 0.13.0 write/impl#[`IoWrite<W>`]new().(&mut vec)).packed_formatrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]packed_format().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 37 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(vec) |
| 38 | } |
| 39 | |
| 40 | /// Serializes a value to a writer. |
| 41 | #[cfg(feature = "std")] |
| 42 | pub fn to_writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_writer().<W, T>(writer: W, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 43 | where |
| 44 | W: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 45 | T: serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 46 | { |
| 47 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#::newrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]new().(&mut IoWriterust-analyzer cargo serde_cbor_2 0.13.0 write/IoWrite#::newrust-analyzer cargo serde_cbor_2 0.13.0 write/impl#[`IoWrite<W>`]new().(writer))) |
| 48 | } |
| 49 | |
| 50 | /// A structure for serializing Rust values to CBOR. |
| 51 | #[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:)] |
| 52 | pub struct Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W> { |
| 53 | writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer.: W, |
| 54 | packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#packed.: bool, |
| 55 | enum_as_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#enum_as_map.: bool, |
| 56 | } |
| 57 | |
| 58 | impl<W> Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W> |
| 59 | where |
| 60 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 61 | { |
| 62 | /// Creates a new CBOR serializer. |
| 63 | /// |
| 64 | /// `to_vec` and `to_writer` should normally be used instead of this method. |
| 65 | #[inline] |
| 66 | pub fn newrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]new().(writer: W) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`] { |
| 67 | Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer# { |
| 68 | writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer., |
| 69 | packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#packed.: false, |
| 70 | enum_as_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#enum_as_map.: true, |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /// Choose concise/packed format for serializer. |
| 75 | /// |
| 76 | /// In the packed format enum variant names and field names |
| 77 | /// are replaced with numeric indizes to conserve space. |
| 78 | pub fn packed_formatrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]packed_format().(mut self) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`] { |
| 79 | self.packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#packed. = true; |
| 80 | self |
| 81 | } |
| 82 | |
| 83 | /// Enable old enum format used by `serde_cbor` versions <= v0.9. |
| 84 | /// |
| 85 | /// The `legacy_enums` option determines how enums are encoded. |
| 86 | /// |
| 87 | /// This makes no difference when encoding and decoding enums using |
| 88 | /// this crate, but it shows up when decoding to a `Value` or decoding |
| 89 | /// in other languages. |
| 90 | /// |
| 91 | /// # Examples |
| 92 | /// |
| 93 | /// Given the following enum |
| 94 | /// |
| 95 | /// ```rust |
| 96 | /// enum Enum { |
| 97 | /// Unit, |
| 98 | /// NewType(i32), |
| 99 | /// Tuple(String, bool), |
| 100 | /// Struct{ x: i32, y: i32 }, |
| 101 | /// } |
| 102 | /// ``` |
| 103 | /// we will give the `Value` with the same encoding for each case using |
| 104 | /// JSON notation. |
| 105 | /// |
| 106 | /// ## Default encodings |
| 107 | /// |
| 108 | /// * `Enum::Unit` encodes as `"Unit"` |
| 109 | /// * `Enum::NewType(10)` encodes as `{"NewType": 10}` |
| 110 | /// * `Enum::Tuple("x", true)` encodes as `{"Tuple": ["x", true]}` |
| 111 | /// |
| 112 | /// ## Legacy encodings |
| 113 | /// |
| 114 | /// * `Enum::Unit` encodes as `"Unit"` |
| 115 | /// * `Enum::NewType(10)` encodes as `["NewType", 10]` |
| 116 | /// * `Enum::Tuple("x", true)` encodes as `["Tuple", "x", true]` |
| 117 | /// * `Enum::Struct{ x: 5, y: -5 }` encodes as `["Struct", {"x": 5, "y": -5}]` |
| 118 | pub fn legacy_enumsrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]legacy_enums().(mut self) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`] { |
| 119 | self.enum_as_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#enum_as_map. = false; |
| 120 | self |
| 121 | } |
| 122 | |
| 123 | /// Writes a CBOR self-describe tag to the stream. |
| 124 | /// |
| 125 | /// Tagging allows a decoder to distinguish different file formats based on their content |
| 126 | /// without further information. |
| 127 | #[inline] |
| 128 | pub fn self_describerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]self_describe().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 129 | let mut buf = [(6 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().25, 0, 0]; |
| 130 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&55799u16.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_be_bytes().()); |
| 131 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 132 | } |
| 133 | |
| 134 | /// Unwrap the `Writer` from the `Serializer`. |
| 135 | #[inline] |
| 136 | pub fn into_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]into_inner().(self) -> W { |
| 137 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer. |
| 138 | } |
| 139 | |
| 140 | #[inline] |
| 141 | fn write_u8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u8().(&mut self, major: u8, value: u8) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 142 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().0x17 { |
| 143 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[(major rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().value]) |
| 144 | } else { |
| 145 | let buf = [(major rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().24, value]; |
| 146 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf) |
| 147 | } |
| 148 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 149 | } |
| 150 | |
| 151 | #[inline] |
| 152 | fn write_u16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u16().(&mut self, major: u8, value: u16) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 153 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]le().u16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`From<u8>`]from().(u8::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]MAX.) { |
| 154 | self.write_u8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u8().(major, value as u8) |
| 155 | } else { |
| 156 | let mut buf = [(major rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().25, 0, 0]; |
| 157 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&value.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_be_bytes().()); |
| 158 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | #[inline] |
| 163 | fn write_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u32().(&mut self, major: u8, value: u32) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 164 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX.) { |
| 165 | self.write_u16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u16().(major, value as u16) |
| 166 | } else { |
| 167 | let mut buf = [(major rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().26, 0, 0, 0, 0]; |
| 168 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&value.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().()); |
| 169 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | #[inline] |
| 174 | fn write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(&mut self, major: u8, value: u64) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 175 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]le().u64::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u32>`]from().(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.) { |
| 176 | self.write_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u32().(major, value as u32) |
| 177 | } else { |
| 178 | let mut buf = [(major rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().27, 0, 0, 0, 0, 0, 0, 0, 0]; |
| 179 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&value.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]to_be_bytes().()); |
| 180 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | #[inline] |
| 185 | fn serialize_collectionrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]serialize_collection().( |
| 186 | &mut self, |
| 187 | major: u8, |
| 188 | len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 189 | ) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'_, W>> { |
| 190 | let needs_eof = match len { |
| 191 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len) => { |
| 192 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(major, len as u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 193 | false |
| 194 | } |
| 195 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 196 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer. |
| 197 | .write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[(major rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().31]) |
| 198 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 199 | true |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer# { |
| 204 | serrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#ser.: self, |
| 205 | needs_eofrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#needs_eof., |
| 206 | }) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | impl<'a, W> serrust-analyzer cargo serde 1.0.144 ser/::Serializerrust-analyzer cargo serde 1.0.144 ser/Serializer# for &'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W> |
| 211 | where |
| 212 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 213 | { |
| 214 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]Ok# = (); |
| 215 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 216 | |
| 217 | type SerializeSeqrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeSeq# = CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'a, W>; |
| 218 | type SerializeTuplerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeTuple# = &'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>; |
| 219 | type SerializeTupleStructrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeTupleStruct# = &'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>; |
| 220 | type SerializeTupleVariantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeTupleVariant# = &'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>; |
| 221 | type SerializeMaprust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeMap# = CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'a, W>; |
| 222 | type SerializeStructrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeStruct# = StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'a, W>; |
| 223 | type SerializeStructVariantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]SerializeStructVariant# = StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'a, W>; |
| 224 | |
| 225 | #[inline] |
| 226 | fn serialize_boolrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_bool().(self, value: bool) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 227 | let value = if value { 0xf5 } else { 0xf4 }; |
| 228 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[value]).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 229 | } |
| 230 | |
| 231 | #[inline] |
| 232 | fn serialize_i8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_i8().(self, value: i8) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 233 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt().0 { |
| 234 | self.write_u8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u8().(1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().(value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1) as u8) |
| 235 | } else { |
| 236 | self.write_u8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u8().(0, value as u8) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | #[inline] |
| 241 | fn serialize_i16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_i16().(self, value: i16) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 242 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { |
| 243 | self.write_u16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u16().(1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().(value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1) as u16) |
| 244 | } else { |
| 245 | self.write_u16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u16().(0, value as u16) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | #[inline] |
| 250 | fn serialize_i32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_i32().(self, value: i32) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 251 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 { |
| 252 | self.write_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u32().(1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().(value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1) as u32) |
| 253 | } else { |
| 254 | self.write_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u32().(0, value as u32) |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | #[inline] |
| 259 | fn serialize_i64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_i64().(self, value: i64) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 260 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().0 { |
| 261 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().(value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().1) as u64) |
| 262 | } else { |
| 263 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(0, value as u64) |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | #[inline] |
| 268 | fn serialize_i128rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_i128().(self, value: i128) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 269 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt().0 { |
| 270 | if -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().(value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt().i128::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i128][`From<u64>`]from().(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.) { |
| 271 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::messagerust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]message().("The number can't be stored in CBOR")); |
| 272 | } |
| 273 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().(value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Add<Self>`]add().1) as u64) |
| 274 | } else { |
| 275 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt().i128::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i128][`From<u64>`]from().(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.) { |
| 276 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::messagerust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]message().("The number can't be stored in CBOR")); |
| 277 | } |
| 278 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(0, value as u64) |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | #[inline] |
| 283 | fn serialize_u8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_u8().(self, value: u8) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 284 | self.write_u8rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u8().(0, value) |
| 285 | } |
| 286 | |
| 287 | #[inline] |
| 288 | fn serialize_u16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_u16().(self, value: u16) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 289 | self.write_u16rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u16().(0, value) |
| 290 | } |
| 291 | |
| 292 | #[inline] |
| 293 | fn serialize_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_u32().(self, value: u32) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 294 | self.write_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u32().(0, value) |
| 295 | } |
| 296 | |
| 297 | #[inline] |
| 298 | fn serialize_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_u64().(self, value: u64) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 299 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(0, value) |
| 300 | } |
| 301 | |
| 302 | #[inline] |
| 303 | fn serialize_u128rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_u128().(self, value: u128) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 304 | if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u128][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u128][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u128][`PartialOrd<Self>`]gt().u128::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u128][`From<u64>`]from().(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.) { |
| 305 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::messagerust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]message().("The number can't be stored in CBOR")); |
| 306 | } |
| 307 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(0, value as u64) |
| 308 | } |
| 309 | |
| 310 | #[inline] |
| 311 | #[allow(clippy::float_cmp)] |
| 312 | fn serialize_f32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_f32().(self, value: f32) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 313 | if value.is_infiniterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]is_infinite().() { |
| 314 | if value.is_sign_positiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]is_sign_positive().() { |
| 315 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[0xf9, 0x7c, 0x00]) |
| 316 | } else { |
| 317 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[0xf9, 0xfc, 0x00]) |
| 318 | } |
| 319 | } else if value.is_nanrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]is_nan().() { |
| 320 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[0xf9, 0x7e, 0x00]) |
| 321 | } else if f32::fromrust-analyzer cargo half 2.6.0 binary16/impl#[f32][`From<f16>`]from().(f16rust-analyzer cargo half 2.6.0 binary16/f16#::from_f32rust-analyzer cargo half 2.6.0 binary16/impl#[f16]from_f32().(value)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialEq<Self>`]eq().value { |
| 322 | let mut buf = [0xf9, 0, 0]; |
| 323 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&f16rust-analyzer cargo half 2.6.0 binary16/f16#::from_f32rust-analyzer cargo half 2.6.0 binary16/impl#[f16]from_f32().(value).to_bitsrust-analyzer cargo half 2.6.0 binary16/impl#[f16]to_bits().().to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_be_bytes().()); |
| 324 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf) |
| 325 | } else { |
| 326 | let mut buf = [0xfa, 0, 0, 0, 0]; |
| 327 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&value.to_bitsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]to_bits().().to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().()); |
| 328 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf) |
| 329 | } |
| 330 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 331 | } |
| 332 | |
| 333 | #[inline] |
| 334 | #[allow(clippy::float_cmp)] |
| 335 | fn serialize_f64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_f64().(self, value: f64) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 336 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().value.is_finiterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_finite().() || f64::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[f64][`From<f32>`]from().(value as f32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq().value { |
| 337 | self.serialize_f32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_f32().(value as f32) |
| 338 | } else { |
| 339 | let mut buf = [0xfb, 0, 0, 0, 0, 0, 0, 0, 0]; |
| 340 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&value.to_bitsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_bits().().to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]to_be_bytes().()); |
| 341 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | #[inline] |
| 346 | fn serialize_charrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_char().(self, value: char) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 347 | // A char encoded as UTF-8 takes 4 bytes at most. |
| 348 | let mut buf = [0; 4]; |
| 349 | self.serialize_strrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_str().(value.encode_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]encode_utf8().(&mut buf)) |
| 350 | } |
| 351 | |
| 352 | #[inline] |
| 353 | fn serialize_strrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_str().(self, value: &str) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 354 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(3, value.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() as u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 355 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer. |
| 356 | .write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(value.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) |
| 357 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 358 | } |
| 359 | |
| 360 | #[inline] |
| 361 | fn serialize_bytesrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_bytes().(self, value: &[u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 362 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(2, value.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 363 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(value).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 364 | } |
| 365 | |
| 366 | #[inline] |
| 367 | fn serialize_unitrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 368 | self.serialize_nonerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_none().() |
| 369 | } |
| 370 | |
| 371 | #[inline] |
| 372 | fn serialize_somerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_some().<T>(self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 373 | where |
| 374 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 375 | { |
| 376 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(self) |
| 377 | } |
| 378 | |
| 379 | #[inline] |
| 380 | fn serialize_nonerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_none().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 381 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[0xf6]).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 382 | } |
| 383 | |
| 384 | #[inline] |
| 385 | fn serialize_unit_structrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit_struct().(self, _name: &'static str) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 386 | self.serialize_unitrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit().() |
| 387 | } |
| 388 | |
| 389 | #[inline] |
| 390 | fn serialize_unit_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit_variant().( |
| 391 | self, |
| 392 | _name: &'static str, |
| 393 | variant_index: u32, |
| 394 | variant: &'static str, |
| 395 | ) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 396 | if self.packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#packed. { |
| 397 | self.serialize_u32rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_u32().(variant_index) |
| 398 | } else { |
| 399 | self.serialize_strrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_str().(variant) |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | #[inline] |
| 404 | fn serialize_newtype_structrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_newtype_struct().<T>(self, name: &'static str, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 405 | where |
| 406 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 407 | { |
| 408 | if name rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().CBOR_NEWTYPE_NAMErust-analyzer cargo serde_cbor_2 0.13.0 tags/CBOR_NEWTYPE_NAME. { |
| 409 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(tag) = get_tagrust-analyzer cargo serde_cbor_2 0.13.0 tags/get_tag().() { |
| 410 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(6, tag)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 411 | } |
| 412 | } |
| 413 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(self) |
| 414 | } |
| 415 | |
| 416 | #[inline] |
| 417 | fn serialize_newtype_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_newtype_variant().<T>( |
| 418 | self, |
| 419 | name: &'static str, |
| 420 | variant_index: u32, |
| 421 | variant: &'static str, |
| 422 | value: &T, |
| 423 | ) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 424 | where |
| 425 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 426 | { |
| 427 | if self.enum_as_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#enum_as_map. { |
| 428 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(5, 1u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 429 | variant.serializerust-analyzer cargo serde 1.0.144 ser/impls/impl#[str][Serialize]serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 430 | } else { |
| 431 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer. |
| 432 | .write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[(4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().2]) |
| 433 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 434 | self.serialize_unit_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit_variant().(name, variant_index, variant)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 435 | } |
| 436 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(self) |
| 437 | } |
| 438 | |
| 439 | #[inline] |
| 440 | fn serialize_seqrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_seq().(self, len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'a, W>> { |
| 441 | self.serialize_collectionrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]serialize_collection().(4, len) |
| 442 | } |
| 443 | |
| 444 | #[inline] |
| 445 | fn serialize_tuplerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_tuple().(self, len: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<&'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>> { |
| 446 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(4, len as u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 447 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self) |
| 448 | } |
| 449 | |
| 450 | #[inline] |
| 451 | fn serialize_tuple_structrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_tuple_struct().( |
| 452 | self, |
| 453 | _name: &'static str, |
| 454 | len: usize, |
| 455 | ) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<&'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>> { |
| 456 | self.serialize_tuplerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_tuple().(len) |
| 457 | } |
| 458 | |
| 459 | #[inline] |
| 460 | fn serialize_tuple_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_tuple_variant().( |
| 461 | self, |
| 462 | name: &'static str, |
| 463 | variant_index: u32, |
| 464 | variant: &'static str, |
| 465 | len: usize, |
| 466 | ) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<&'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>> { |
| 467 | if self.enum_as_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#enum_as_map. { |
| 468 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(5, 1u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 469 | variant.serializerust-analyzer cargo serde 1.0.144 ser/impls/impl#[str][Serialize]serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 470 | self.serialize_tuplerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_tuple().(len) |
| 471 | } else { |
| 472 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(4, (len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) as u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 473 | self.serialize_unit_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit_variant().(name, variant_index, variant)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 474 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self) |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | #[inline] |
| 479 | fn serialize_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_map().(self, len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'a, W>> { |
| 480 | self.serialize_collectionrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]serialize_collection().(5, len) |
| 481 | } |
| 482 | |
| 483 | #[cfg(not(feature = "std"))] |
| 484 | fn collect_str<T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 485 | where |
| 486 | T: corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, |
| 487 | { |
| 488 | use craterust-analyzer cargo serde_cbor_2 0.13.0 crate/::writerust-analyzer cargo serde_cbor_2 0.13.0 write/::FmtWrite; |
| 489 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#; |
| 490 | |
| 491 | let mut w = FmtWrite::new(&mut selfrust-analyzer cargo serde_cbor_2 0.13.0 ser/.writer); |
| 492 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(w, "{}", value)?; |
| 493 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 494 | } |
| 495 | |
| 496 | #[inline] |
| 497 | fn serialize_structrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_struct().(self, _name: &'static str, len: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'a, W>> { |
| 498 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(5, len as u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 499 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer# { serrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#ser.: self, idxrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#idx.: 0 }) |
| 500 | } |
| 501 | |
| 502 | #[inline] |
| 503 | fn serialize_struct_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_struct_variant().( |
| 504 | self, |
| 505 | name: &'static str, |
| 506 | variant_index: u32, |
| 507 | variant: &'static str, |
| 508 | len: usize, |
| 509 | ) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'a, W>> { |
| 510 | if self.enum_as_maprust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#enum_as_map. { |
| 511 | self.write_u64rust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]write_u64().(5, 1u64)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 512 | } else { |
| 513 | self.writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer. |
| 514 | .write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[(4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().5) 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().2]) |
| 515 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 516 | } |
| 517 | self.serialize_unit_variantrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_unit_variant().(name, variant_index, variant)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 518 | self.serialize_structrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]serialize_struct().(name, len) |
| 519 | } |
| 520 | |
| 521 | #[inline] |
| 522 | fn is_human_readablerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&'a mut Serializer<W>`][Serializer]is_human_readable().(&self) -> bool { |
| 523 | false |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeTuplerust-analyzer cargo serde 1.0.144 ser/SerializeTuple# for &mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W> |
| 528 | where |
| 529 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 530 | { |
| 531 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTuple]Ok# = (); |
| 532 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTuple]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 533 | |
| 534 | #[inline] |
| 535 | fn serialize_elementrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTuple]serialize_element().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 536 | where |
| 537 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 538 | { |
| 539 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 540 | } |
| 541 | |
| 542 | #[inline] |
| 543 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTuple]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 544 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeTupleStructrust-analyzer cargo serde 1.0.144 ser/SerializeTupleStruct# for &mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W> |
| 549 | where |
| 550 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 551 | { |
| 552 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleStruct]Ok# = (); |
| 553 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleStruct]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 554 | |
| 555 | #[inline] |
| 556 | fn serialize_fieldrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleStruct]serialize_field().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 557 | where |
| 558 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 559 | { |
| 560 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 561 | } |
| 562 | |
| 563 | #[inline] |
| 564 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleStruct]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 565 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeTupleVariantrust-analyzer cargo serde 1.0.144 ser/SerializeTupleVariant# for &mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W> |
| 570 | where |
| 571 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 572 | { |
| 573 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleVariant]Ok# = (); |
| 574 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleVariant]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 575 | |
| 576 | #[inline] |
| 577 | fn serialize_fieldrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleVariant]serialize_field().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 578 | where |
| 579 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 580 | { |
| 581 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 582 | } |
| 583 | |
| 584 | #[inline] |
| 585 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`&mut Serializer<W>`][SerializeTupleVariant]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 586 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | #[doc(hidden)] |
| 591 | pub struct StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'a, W> { |
| 592 | serrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#ser.: &'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>, |
| 593 | idxrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#idx.: u32, |
| 594 | } |
| 595 | |
| 596 | impl<W> StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'_, W> |
| 597 | where |
| 598 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 599 | { |
| 600 | #[inline] |
| 601 | fn serialize_field_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]serialize_field_inner().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 602 | where |
| 603 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 604 | { |
| 605 | if self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#ser..packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#packed. { |
| 606 | self.idxrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#idx..serializerust-analyzer cargo serde 1.0.144 ser/impls/impl#[u32][Serialize]serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#ser.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 607 | } else { |
| 608 | key.serializerust-analyzer cargo serde 1.0.144 ser/impls/impl#[str][Serialize]serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#ser.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 609 | } |
| 610 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#ser.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 611 | self.idxrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#idx. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().1; |
| 612 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 613 | } |
| 614 | |
| 615 | #[inline] |
| 616 | fn skip_field_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]skip_field_inner().(&mut self, _: &'static str) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 617 | self.idxrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#idx. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().1; |
| 618 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 619 | } |
| 620 | |
| 621 | #[inline] |
| 622 | fn end_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]end_inner().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 623 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeStructrust-analyzer cargo serde 1.0.144 ser/SerializeStruct# for StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'_, W> |
| 628 | where |
| 629 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 630 | { |
| 631 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStruct]Ok# = (); |
| 632 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStruct]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 633 | |
| 634 | #[inline] |
| 635 | fn serialize_fieldrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStruct]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 636 | where |
| 637 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 638 | { |
| 639 | self.serialize_field_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]serialize_field_inner().(key, value) |
| 640 | } |
| 641 | |
| 642 | #[inline] |
| 643 | fn skip_fieldrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStruct]skip_field().(&mut self, key: &'static str) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 644 | self.skip_field_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]skip_field_inner().(key) |
| 645 | } |
| 646 | |
| 647 | #[inline] |
| 648 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStruct]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 649 | self.end_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]end_inner().() |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeStructVariantrust-analyzer cargo serde 1.0.144 ser/SerializeStructVariant# for StructSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/StructSerializer#<'_, W> |
| 654 | where |
| 655 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 656 | { |
| 657 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStructVariant]Ok# = (); |
| 658 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStructVariant]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 659 | |
| 660 | #[inline] |
| 661 | fn serialize_fieldrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStructVariant]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 662 | where |
| 663 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 664 | { |
| 665 | self.serialize_field_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]serialize_field_inner().(key, value) |
| 666 | } |
| 667 | |
| 668 | #[inline] |
| 669 | fn skip_fieldrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStructVariant]skip_field().(&mut self, key: &'static str) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 670 | self.skip_field_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]skip_field_inner().(key) |
| 671 | } |
| 672 | |
| 673 | #[inline] |
| 674 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`][SerializeStructVariant]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 675 | self.end_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`StructSerializer<'_, W>`]end_inner().() |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | #[doc(hidden)] |
| 680 | pub struct CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'a, W> { |
| 681 | serrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#ser.: &'a mut Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#<W>, |
| 682 | needs_eofrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#needs_eof.: bool, |
| 683 | } |
| 684 | |
| 685 | impl<W> CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'_, W> |
| 686 | where |
| 687 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 688 | { |
| 689 | #[inline] |
| 690 | fn end_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`]end_inner().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 691 | if self.needs_eofrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#needs_eof. { |
| 692 | self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#ser..writerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#writer..write_allrust-analyzer cargo serde_cbor_2 0.13.0 write/Write#write_all().(&[0xff]).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 693 | } else { |
| 694 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 695 | } |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeSeqrust-analyzer cargo serde 1.0.144 ser/SerializeSeq# for CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'_, W> |
| 700 | where |
| 701 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 702 | { |
| 703 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeSeq]Ok# = (); |
| 704 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeSeq]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 705 | |
| 706 | #[inline] |
| 707 | fn serialize_elementrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeSeq]serialize_element().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 708 | where |
| 709 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 710 | { |
| 711 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#ser.) |
| 712 | } |
| 713 | |
| 714 | #[inline] |
| 715 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeSeq]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 716 | self.end_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`]end_inner().() |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | impl<W> serrust-analyzer cargo serde 1.0.144 ser/::SerializeMaprust-analyzer cargo serde 1.0.144 ser/SerializeMap# for CollectionSerializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#<'_, W> |
| 721 | where |
| 722 | W: Writerust-analyzer cargo serde_cbor_2 0.13.0 write/Write#, |
| 723 | { |
| 724 | type Okrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeMap]Ok# = (); |
| 725 | type Errorrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeMap]Error# = Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#; |
| 726 | |
| 727 | #[inline] |
| 728 | fn serialize_keyrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeMap]serialize_key().<T>(&mut self, key: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 729 | where |
| 730 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 731 | { |
| 732 | key.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#ser.) |
| 733 | } |
| 734 | |
| 735 | #[inline] |
| 736 | fn serialize_valuerust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeMap]serialize_value().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> |
| 737 | where |
| 738 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serrust-analyzer cargo serde 1.0.144 ser/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#, |
| 739 | { |
| 740 | value.serializerust-analyzer cargo serde 1.0.144 ser/Serialize#serialize().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.serrust-analyzer cargo serde_cbor_2 0.13.0 ser/CollectionSerializer#ser.) |
| 741 | } |
| 742 | |
| 743 | #[inline] |
| 744 | fn endrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`][SerializeMap]end().(self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> { |
| 745 | self.end_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`CollectionSerializer<'_, W>`]end_inner().() |
| 746 | } |
| 747 | } |