| 1 | use craterust-analyzer cargo bendy 0.6.1 crate/::serderust-analyzer cargo bendy 0.6.1 serde/::commonrust-analyzer cargo bendy 0.6.1 serde/common/::*; |
| 2 | |
| 3 | /// Bencode sub-serializer for structs. |
| 4 | pub struct StructSerializerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#<'outer> { |
| 5 | pub(craterust-analyzer cargo bendy 0.6.1 crate/) outerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#outer.: &'outer mut Encoderrust-analyzer cargo bendy 0.6.1 encoding/encoder/Encoder#, |
| 6 | encoderrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#encoder.: UnsortedDictEncoderrust-analyzer cargo bendy 0.6.1 encoding/encoder/UnsortedDictEncoder#, |
| 7 | } |
| 8 | |
| 9 | impl<'outer> StructSerializerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#<'outer> { |
| 10 | pub(craterust-analyzer cargo bendy 0.6.1 crate/) fn newrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`]new().( |
| 11 | outer: &'outer mut Encoderrust-analyzer cargo bendy 0.6.1 encoding/encoder/Encoder#, |
| 12 | encoder: UnsortedDictEncoderrust-analyzer cargo bendy 0.6.1 encoding/encoder/UnsortedDictEncoder#, |
| 13 | ) -> StructSerializerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#<'outer> { |
| 14 | StructSerializerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer# { outerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#outer., encoderrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#encoder. } |
| 15 | } |
| 16 | |
| 17 | fn save_fieldrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`]save_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo bendy 0.6.1 serde/error/Result#<()> |
| 18 | where |
| 19 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde 1.0.140 ser/Serialize#, |
| 20 | { |
| 21 | let mut serializer = Serializerrust-analyzer cargo bendy 0.6.1 serde/ser/Serializer#::with_max_depthrust-analyzer cargo bendy 0.6.1 serde/ser/impl#[Serializer]with_max_depth().(self.encoderrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#encoder..remaining_depthrust-analyzer cargo bendy 0.6.1 encoding/encoder/impl#[UnsortedDictEncoder]remaining_depth().()); |
| 22 | value.serializerust-analyzer cargo serde 1.0.140 ser/Serialize#serialize().(&mut serializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 23 | let value_bytes = serializer.into_bytesrust-analyzer cargo bendy 0.6.1 serde/ser/impl#[Serializer]into_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 24 | |
| 25 | self.encoderrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#encoder..save_pairrust-analyzer cargo bendy 0.6.1 encoding/encoder/impl#[UnsortedDictEncoder]save_pair().(key.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), value_bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | |
| 27 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl<'outer> SerializeStructrust-analyzer cargo serde 1.0.140 ser/SerializeStruct# for StructSerializerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#<'outer> { |
| 32 | type Errorrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStruct]Error# = Errorrust-analyzer cargo bendy 0.6.1 serde/error/Error#; |
| 33 | type Okrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStruct]Ok# = (); |
| 34 | |
| 35 | fn serialize_fieldrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStruct]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo bendy 0.6.1 serde/error/Result#<()> |
| 36 | where |
| 37 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde 1.0.140 ser/Serialize#, |
| 38 | { |
| 39 | self.save_fieldrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`]save_field().(key, value) |
| 40 | } |
| 41 | |
| 42 | fn endrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStruct]end().(self) -> Resultrust-analyzer cargo bendy 0.6.1 serde/error/Result#<()> { |
| 43 | self.outerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#outer..end_unsorted_dictrust-analyzer cargo bendy 0.6.1 encoding/encoder/impl#[Encoder]end_unsorted_dict().(self.encoderrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#encoder.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 44 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | impl<'outer> SerializeStructVariantrust-analyzer cargo serde 1.0.140 ser/SerializeStructVariant# for StructSerializerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#<'outer> { |
| 49 | type Errorrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStructVariant]Error# = Errorrust-analyzer cargo bendy 0.6.1 serde/error/Error#; |
| 50 | type Okrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStructVariant]Ok# = (); |
| 51 | |
| 52 | fn serialize_fieldrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStructVariant]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo bendy 0.6.1 serde/error/Result#<()> |
| 53 | where |
| 54 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde 1.0.140 ser/Serialize#, |
| 55 | { |
| 56 | self.save_fieldrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`]save_field().(key, value) |
| 57 | } |
| 58 | |
| 59 | fn endrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/impl#[`StructSerializer<'outer>`][SerializeStructVariant]end().(self) -> Resultrust-analyzer cargo bendy 0.6.1 serde/error/Result#<()> { |
| 60 | self.outerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#outer..end_unsorted_dictrust-analyzer cargo bendy 0.6.1 encoding/encoder/impl#[Encoder]end_unsorted_dict().(self.encoderrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#encoder.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 61 | self.outerrust-analyzer cargo bendy 0.6.1 serde/ser/struct_serializer/StructSerializer#outer..emit_tokenrust-analyzer cargo bendy 0.6.1 encoding/encoder/impl#[Encoder]emit_token().(Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 62 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 63 | } |
| 64 | } |