| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#; |
| 2 | |
| 3 | #[cfg(feature = "arbitrary_precision")] |
| 4 | use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::typesrust-analyzer cargo pyo3 0.28.1 types/::{PyAnyMethodsrust-analyzer cargo pyo3 0.28.1 types/any/PyAnyMethods#, PyFloatrust-analyzer cargo pyo3 0.28.1 types/float/PyFloat#, PyIntrust-analyzer cargo pyo3 0.28.1 types/num/PyInt#}; |
| 5 | use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::typesrust-analyzer cargo pyo3 0.28.1 types/::{ |
| 6 | PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#, PyDictMethodsrust-analyzer cargo pyo3 0.28.1 types/dict/PyDictMethods#, PyListrust-analyzer cargo pyo3 0.28.1 types/list/PyList#, PyListMethodsrust-analyzer cargo pyo3 0.28.1 types/list/PyListMethods#, PyMappingrust-analyzer cargo pyo3 0.28.1 types/mapping/PyMapping#, PySequencerust-analyzer cargo pyo3 0.28.1 types/sequence/PySequence#, PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#, PyTuplerust-analyzer cargo pyo3 0.28.1 types/tuple/PyTuple#, |
| 7 | PyTupleMethodsrust-analyzer cargo pyo3 0.28.1 types/tuple/PyTupleMethods#, |
| 8 | }; |
| 9 | use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::{Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#, BoundObjectrust-analyzer cargo pyo3 0.28.1 instance/BoundObject#, IntoPyObjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#, PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#, Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#}; |
| 10 | use serderust-analyzer cargo serde 1.0.228 crate/::{serrust-analyzer cargo serde_core 1.0.228 ser/, Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#}; |
| 11 | |
| 12 | use craterust-analyzer cargo pythonize 0.28.0 crate/::errorrust-analyzer cargo pythonize 0.28.0 error/::{PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#, Resultrust-analyzer cargo pythonize 0.28.0 error/Result#}; |
| 13 | |
| 14 | /// Trait for types which can represent a Python mapping |
| 15 | pub trait PythonizeMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType# { |
| 16 | /// Builder type for Python mappings |
| 17 | type Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>: 'py; |
| 18 | |
| 19 | /// Create a builder for a Python mapping |
| 20 | fn builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#builder().<'py>(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Self::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>>; |
| 21 | |
| 22 | /// Adds the key-value item to the mapping being built |
| 23 | fn push_itemrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#push_item().<'py>( |
| 24 | builder: &mut Self::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>, |
| 25 | key: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>, |
| 26 | value: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>, |
| 27 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<()>; |
| 28 | |
| 29 | /// Build the Python mapping |
| 30 | fn finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#finish().<'py>(builder: Self::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyMappingrust-analyzer cargo pyo3 0.28.1 types/mapping/PyMapping#>>; |
| 31 | } |
| 32 | |
| 33 | /// Trait for types which can represent a Python mapping and have a name |
| 34 | pub trait PythonizeNamedMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType# { |
| 35 | /// Builder type for Python mappings with a name |
| 36 | type Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>: 'py; |
| 37 | |
| 38 | /// Create a builder for a Python mapping with a name |
| 39 | fn builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#builder().<'py>( |
| 40 | py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 41 | len: usize, |
| 42 | name: &'static str, |
| 43 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Self::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>>; |
| 44 | |
| 45 | /// Adds the field to the named mapping being built |
| 46 | fn push_fieldrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#push_field().<'py>( |
| 47 | builder: &mut Self::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>, |
| 48 | name: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#>, |
| 49 | value: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>, |
| 50 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<()>; |
| 51 | |
| 52 | /// Build the Python mapping |
| 53 | fn finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#finish().<'py>(builder: Self::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyMappingrust-analyzer cargo pyo3 0.28.1 types/mapping/PyMapping#>>; |
| 54 | } |
| 55 | |
| 56 | /// Trait for types which can represent a Python sequence |
| 57 | pub trait PythonizeListTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeListType#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# { |
| 58 | /// Constructor |
| 59 | fn create_sequencerust-analyzer cargo pythonize 0.28.0 ser/PythonizeListType#create_sequence().<'py, T, U>( |
| 60 | py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 61 | elements: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = T, IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# = U>, |
| 62 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PySequencerust-analyzer cargo pyo3 0.28.1 types/sequence/PySequence#>> |
| 63 | where |
| 64 | T: IntoPyObjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#<'py>, |
| 65 | U: ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = T>; |
| 66 | } |
| 67 | |
| 68 | /// Custom types for serialization |
| 69 | pub trait PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes# { |
| 70 | /// Python map type (should be representable as python mapping) |
| 71 | type Maprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#Map#: PythonizeMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#; |
| 72 | /// Python (struct-like) named map type (should be representable as python mapping) |
| 73 | type NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#: PythonizeNamedMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#; |
| 74 | /// Python sequence type (should be representable as python sequence) |
| 75 | type Listrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#List#: PythonizeListTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeListType#; |
| 76 | } |
| 77 | |
| 78 | impl PythonizeMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType# for PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict# { |
| 79 | type Builderrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]Builder#<'py> = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]>; |
| 80 | |
| 81 | fn builderrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]builder().<'py>(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, _len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>> { |
| 82 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py)) |
| 83 | } |
| 84 | |
| 85 | fn push_itemrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]push_item().<'py>( |
| 86 | builder: &mut Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>, |
| 87 | key: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>, |
| 88 | value: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>, |
| 89 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<()> { |
| 90 | builder.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().(key, value) |
| 91 | } |
| 92 | |
| 93 | fn finishrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]finish().<'py>(builder: Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[PyDict][PythonizeMappingType]::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyMappingrust-analyzer cargo pyo3 0.28.1 types/mapping/PyMapping#>> { |
| 94 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(builder.into_mappingrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]into_mapping().()) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /// Adapter type to use an unnamed mapping type, i.e. one that implements |
| 99 | /// [`PythonizeMappingType`], as a named mapping type, i.e. one that implements |
| 100 | /// [`PythonizeNamedMappingType`]. The adapter simply drops the provided name. |
| 101 | /// |
| 102 | /// This adapter is commonly applied to use the same unnamed mapping type for |
| 103 | /// both [`PythonizeTypes::Map`] and [`PythonizeTypes::NamedMap`] while only |
| 104 | /// implementing [`PythonizeMappingType`]. |
| 105 | pub struct PythonizeUnnamedMappingAdapterrust-analyzer cargo pythonize 0.28.0 ser/PythonizeUnnamedMappingAdapter#<T: PythonizeMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#> { |
| 106 | _unnamedrust-analyzer cargo pythonize 0.28.0 ser/PythonizeUnnamedMappingAdapter#_unnamed.: T, |
| 107 | } |
| 108 | |
| 109 | impl<T: PythonizeMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#> PythonizeNamedMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType# for PythonizeUnnamedMappingAdapterrust-analyzer cargo pythonize 0.28.0 ser/PythonizeUnnamedMappingAdapter#<T> { |
| 110 | type Builderrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]Builder#<'py> = T::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>; |
| 111 | |
| 112 | fn builderrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]builder().<'py>( |
| 113 | py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 114 | len: usize, |
| 115 | _name: &'static str, |
| 116 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>> { |
| 117 | T::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#builder().(py, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len)) |
| 118 | } |
| 119 | |
| 120 | fn push_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]push_field().<'py>( |
| 121 | builder: &mut Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>, |
| 122 | name: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#>, |
| 123 | value: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>, |
| 124 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<()> { |
| 125 | T::push_itemrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#push_item().(builder, name.into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().(), value) |
| 126 | } |
| 127 | |
| 128 | fn finishrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]finish().<'py>(builder: Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonizeUnnamedMappingAdapter<T>`][PythonizeNamedMappingType]::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyMappingrust-analyzer cargo pyo3 0.28.1 types/mapping/PyMapping#>> { |
| 129 | T::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#finish().(builder) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | impl PythonizeListTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeListType# for PyListrust-analyzer cargo pyo3 0.28.1 types/list/PyList# { |
| 134 | fn create_sequencerust-analyzer cargo pythonize 0.28.0 ser/impl#[PyList][PythonizeListType]create_sequence().<'py, T, U>( |
| 135 | py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 136 | elements: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = T, IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# = U>, |
| 137 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PySequencerust-analyzer cargo pyo3 0.28.1 types/sequence/PySequence#>> |
| 138 | where |
| 139 | T: IntoPyObjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#<'py>, |
| 140 | U: ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = T>, |
| 141 | { |
| 142 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyListrust-analyzer cargo pyo3 0.28.1 types/list/PyList#::newrust-analyzer cargo pyo3 0.28.1 types/list/impl#[PyList]new().(py, elements)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_sequencerust-analyzer cargo pyo3 0.28.1 types/list/impl#[`Bound<'py, PyList>`][`PyListMethods<'py>`]into_sequence().()) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | impl PythonizeListTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeListType# for PyTuplerust-analyzer cargo pyo3 0.28.1 types/tuple/PyTuple# { |
| 147 | fn create_sequencerust-analyzer cargo pythonize 0.28.0 ser/impl#[PyTuple][PythonizeListType]create_sequence().<'py, T, U>( |
| 148 | py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 149 | elements: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = T, IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# = U>, |
| 150 | ) -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PySequencerust-analyzer cargo pyo3 0.28.1 types/sequence/PySequence#>> |
| 151 | where |
| 152 | T: IntoPyObjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#<'py>, |
| 153 | U: ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = T>, |
| 154 | { |
| 155 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyTuplerust-analyzer cargo pyo3 0.28.1 types/tuple/PyTuple#::newrust-analyzer cargo pyo3 0.28.1 types/tuple/impl#[PyTuple]new().(py, elements)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_sequencerust-analyzer cargo pyo3 0.28.1 types/tuple/impl#[`Bound<'py, PyTuple>`][`PyTupleMethods<'py>`]into_sequence().()) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | pub struct PythonizeDefaultrust-analyzer cargo pythonize 0.28.0 ser/PythonizeDefault#; |
| 160 | |
| 161 | impl PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes# for PythonizeDefaultrust-analyzer cargo pythonize 0.28.0 ser/PythonizeDefault# { |
| 162 | type Maprust-analyzer cargo pythonize 0.28.0 ser/impl#[PythonizeDefault][PythonizeTypes]Map# = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#; |
| 163 | type NamedMaprust-analyzer cargo pythonize 0.28.0 ser/impl#[PythonizeDefault][PythonizeTypes]NamedMap# = PythonizeUnnamedMappingAdapterrust-analyzer cargo pythonize 0.28.0 ser/PythonizeUnnamedMappingAdapter#<PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#>; |
| 164 | type Listrust-analyzer cargo pythonize 0.28.0 ser/impl#[PythonizeDefault][PythonizeTypes]List# = PyListrust-analyzer cargo pyo3 0.28.1 types/list/PyList#; |
| 165 | } |
| 166 | |
| 167 | /// Attempt to convert the given data into a Python object |
| 168 | pub fn pythonizerust-analyzer cargo pythonize 0.28.0 ser/pythonize().<'py, T>(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> |
| 169 | where |
| 170 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 171 | { |
| 172 | value.serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#serialize().(Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#::newrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, PythonizeDefault>`]new().(py)) |
| 173 | } |
| 174 | |
| 175 | /// Attempt to convert the given data into a Python object. |
| 176 | /// Also uses custom mapping python class for serialization. |
| 177 | pub fn pythonize_customrust-analyzer cargo pythonize 0.28.0 ser/pythonize_custom().<'py, P, T>(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> |
| 178 | where |
| 179 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 180 | P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#, |
| 181 | { |
| 182 | value.serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#serialize().(Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#::customrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, PythonizeDefault>`]custom().::<P>(py)) |
| 183 | } |
| 184 | |
| 185 | /// A structure that serializes Rust values into Python objects |
| 186 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 187 | pub struct Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#<'py, P> { |
| 188 | pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py.: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 189 | _typesrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<P>, |
| 190 | } |
| 191 | |
| 192 | impl<'py, P> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>> for Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#<'py, P> { |
| 193 | fn fromrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`]from().(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>) -> Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`] { |
| 194 | Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`] { |
| 195 | pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 196 | _typesrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | impl<'py> Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#<'py, PythonizeDefaultrust-analyzer cargo pythonize 0.28.0 ser/PythonizeDefault#> { |
| 202 | /// Creates a serializer to convert data into a Python object using the default mapping class |
| 203 | pub fn newrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, PythonizeDefault>`]new().(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>) -> Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, PythonizeDefault>`] { |
| 204 | Selfrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, PythonizeDefault>`]::fromrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`]from().(py) |
| 205 | } |
| 206 | |
| 207 | /// Creates a serializer to convert data into a Python object using a custom mapping class |
| 208 | pub fn customrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, PythonizeDefault>`]custom().<P>(py: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>) -> Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#<'py, P> { |
| 209 | Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#::fromrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`]from().(py) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | #[doc(hidden)] |
| 214 | pub struct PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P> { |
| 215 | itemsrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#items.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>>, |
| 216 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py.: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 217 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<P>, |
| 218 | } |
| 219 | |
| 220 | #[doc(hidden)] |
| 221 | pub struct PythonTupleVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#<'py, P> { |
| 222 | namerust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#name.: &'static str, |
| 223 | variantrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#variant.: &'static str, |
| 224 | innerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#inner.: PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>, |
| 225 | } |
| 226 | |
| 227 | #[doc(hidden)] |
| 228 | pub struct PythonStructVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> { |
| 229 | namerust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#name.: &'static str, |
| 230 | variantrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#variant.: &'static str, |
| 231 | innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner.: PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#<'py, P>, |
| 232 | } |
| 233 | |
| 234 | #[cfg(feature = "arbitrary_precision")] |
| 235 | #[doc(hidden)] |
| 236 | pub enum StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> { |
| 237 | Structrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Struct#(PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#<'py, P>), |
| 238 | Numberrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number# { |
| 239 | pyrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#py.: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 240 | number_stringrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#number_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 241 | _typesrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<P>, |
| 242 | }, |
| 243 | } |
| 244 | |
| 245 | #[cfg(not(feature = "arbitrary_precision"))] |
| 246 | #[doc(hidden)] |
| 247 | pub type StructSerializer<'py, P> = PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#<'py, P>; |
| 248 | |
| 249 | #[doc(hidden)] |
| 250 | pub struct PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> { |
| 251 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py.: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 252 | builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder.: <P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap# as PythonizeNamedMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#>::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#Builder#<'py>, |
| 253 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<P>, |
| 254 | } |
| 255 | |
| 256 | #[doc(hidden)] |
| 257 | pub struct PythonMapSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> { |
| 258 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#py.: Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#<'py>, |
| 259 | builderrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#builder.: <P::Maprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#Map# as PythonizeMappingTyperust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#>::Builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#Builder#<'py>, |
| 260 | keyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#key.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>>, |
| 261 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<P>, |
| 262 | } |
| 263 | |
| 264 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#<'py, P> { |
| 265 | /// The default implementation for serialisation functions. |
| 266 | #[inline] |
| 267 | fn serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().<T>(self, v: T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> |
| 268 | where |
| 269 | T: IntoPyObjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#<'py>, |
| 270 | <T as IntoPyObjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#<'py>>::Errorrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#Error#: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#>, |
| 271 | { |
| 272 | v.into_pyobjectrust-analyzer cargo pyo3 0.28.1 conversion/IntoPyObject#into_pyobject().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py.) |
| 273 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|x| x.into_anyrust-analyzer cargo pyo3 0.28.1 instance/BoundObject#into_any().().into_boundrust-analyzer cargo pyo3 0.28.1 instance/BoundObject#into_bound().()) |
| 274 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer# for Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#<'py, P> { |
| 279 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 280 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 281 | type SerializeSeqrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeSeq# = PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>; |
| 282 | type SerializeTuplerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeTuple# = PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>; |
| 283 | type SerializeTupleStructrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeTupleStruct# = PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>; |
| 284 | type SerializeTupleVariantrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeTupleVariant# = PythonTupleVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#<'py, P>; |
| 285 | type SerializeMaprust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeMap# = PythonMapSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#<'py, P>; |
| 286 | type SerializeStructrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeStruct# = StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#<'py, P>; |
| 287 | type SerializeStructVariantrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]SerializeStructVariant# = PythonStructVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#<'py, P>; |
| 288 | |
| 289 | fn serialize_boolrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_bool().(self, v: bool) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 290 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 291 | } |
| 292 | |
| 293 | fn serialize_i8rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_i8().(self, v: i8) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 294 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 295 | } |
| 296 | |
| 297 | fn serialize_i16rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_i16().(self, v: i16) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 298 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 299 | } |
| 300 | |
| 301 | fn serialize_i32rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_i32().(self, v: i32) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 302 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 303 | } |
| 304 | |
| 305 | fn serialize_i64rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_i64().(self, v: i64) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 306 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 307 | } |
| 308 | |
| 309 | fn serialize_u8rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_u8().(self, v: u8) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 310 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 311 | } |
| 312 | |
| 313 | fn serialize_u16rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_u16().(self, v: u16) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 314 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 315 | } |
| 316 | |
| 317 | fn serialize_u32rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_u32().(self, v: u32) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 318 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 319 | } |
| 320 | |
| 321 | fn serialize_u64rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_u64().(self, v: u64) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 322 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 323 | } |
| 324 | |
| 325 | fn serialize_f32rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_f32().(self, v: f32) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 326 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 327 | } |
| 328 | |
| 329 | fn serialize_f64rust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_f64().(self, v: f64) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 330 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 331 | } |
| 332 | |
| 333 | fn serialize_charrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_char().(self, v: char) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 334 | self.serialize_strrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_str().(&v.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 335 | } |
| 336 | |
| 337 | fn serialize_strrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_str().(self, v: &str) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 338 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#::newrust-analyzer cargo pyo3 0.28.1 types/string/impl#[PyString]new().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., v).into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 339 | } |
| 340 | |
| 341 | fn serialize_bytesrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_bytes().(self, v: &[u8]) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 342 | self.serialise_defaultrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`]serialise_default().(v) |
| 343 | } |
| 344 | |
| 345 | fn serialize_nonerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_none().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 346 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py..Nonerust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'py>`]None().().into_boundrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Py<T>`]into_bound().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py.)) |
| 347 | } |
| 348 | |
| 349 | fn serialize_somerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_some().<T>(self, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> |
| 350 | where |
| 351 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 352 | { |
| 353 | value.serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#serialize().(self) |
| 354 | } |
| 355 | |
| 356 | fn serialize_unitrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_unit().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 357 | self.serialize_nonerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_none().() |
| 358 | } |
| 359 | |
| 360 | fn serialize_unit_structrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_unit_struct().(self, _name: &'static str) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 361 | self.serialize_nonerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_none().() |
| 362 | } |
| 363 | |
| 364 | fn serialize_unit_variantrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_unit_variant().( |
| 365 | self, |
| 366 | _name: &'static str, |
| 367 | _variant_index: u32, |
| 368 | variant: &'static str, |
| 369 | ) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 370 | self.serialize_strrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_str().(variant) |
| 371 | } |
| 372 | |
| 373 | fn serialize_newtype_structrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_newtype_struct().<T>( |
| 374 | self, |
| 375 | _name: &'static str, |
| 376 | value: &T, |
| 377 | ) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> |
| 378 | where |
| 379 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 380 | { |
| 381 | value.serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#serialize().(self) |
| 382 | } |
| 383 | |
| 384 | fn serialize_newtype_variantrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_newtype_variant().<T>( |
| 385 | self, |
| 386 | name: &'static str, |
| 387 | _variant_index: u32, |
| 388 | variant: &'static str, |
| 389 | value: &T, |
| 390 | ) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> |
| 391 | where |
| 392 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 393 | { |
| 394 | let mut m = P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#builder().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., 1, name)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 395 | P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::push_fieldrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#push_field().( |
| 396 | &mut m, |
| 397 | PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#::newrust-analyzer cargo pyo3 0.28.1 types/string/impl#[PyString]new().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., variant), |
| 398 | value.serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#serialize().(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 399 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 400 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#finish().(m)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 401 | } |
| 402 | |
| 403 | fn serialize_seqrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_seq().(self, len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>> { |
| 404 | let items = match len { |
| 405 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len) => Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(len), |
| 406 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => 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().(), |
| 407 | }; |
| 408 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer# { |
| 409 | itemsrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#items., |
| 410 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py.: self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 411 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 412 | }) |
| 413 | } |
| 414 | |
| 415 | fn serialize_tuplerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_tuple().(self, len: usize) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>> { |
| 416 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer# { |
| 417 | itemsrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#items.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(len), |
| 418 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py.: self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 419 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 420 | }) |
| 421 | } |
| 422 | |
| 423 | fn serialize_tuple_structrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_tuple_struct().( |
| 424 | self, |
| 425 | _name: &'static str, |
| 426 | len: usize, |
| 427 | ) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P>> { |
| 428 | self.serialize_tuplerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_tuple().(len) |
| 429 | } |
| 430 | |
| 431 | fn serialize_tuple_variantrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_tuple_variant().( |
| 432 | self, |
| 433 | name: &'static str, |
| 434 | _variant_index: u32, |
| 435 | variant: &'static str, |
| 436 | len: usize, |
| 437 | ) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<PythonTupleVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#<'py, P>> { |
| 438 | let inner = self.serialize_tuplerust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_tuple().(len)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 439 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PythonTupleVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer# { |
| 440 | namerust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#name., |
| 441 | variantrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#variant., |
| 442 | innerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#inner., |
| 443 | }) |
| 444 | } |
| 445 | |
| 446 | fn serialize_maprust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_map().(self, len: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<PythonMapSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#<'py, P>> { |
| 447 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PythonMapSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer# { |
| 448 | builderrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#builder.: P::Maprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#Map#::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#builder().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., len)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 449 | keyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#key.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 450 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#py.: self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 451 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 452 | }) |
| 453 | } |
| 454 | |
| 455 | fn serialize_structrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_struct().(self, name: &'static str, len: usize) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#<'py, P>> { |
| 456 | #[cfg(feature = "arbitrary_precision")] |
| 457 | { |
| 458 | // With arbitrary_precision enabled, a serde_json::Number serializes as a "$serde_json::private::Number" |
| 459 | // struct with a "$serde_json::private::Number" field, whose value is the String in Number::n. |
| 460 | 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()."$serde_json::private::Number" && len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 461 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Numberrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number# { |
| 462 | pyrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#py.: self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 463 | number_stringrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#number_string.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 464 | _typesrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 465 | }); |
| 466 | } |
| 467 | |
| 468 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Structrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Struct#(PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer# { |
| 469 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py.: self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 470 | builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder.: P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#builder().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., len, name)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 471 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 472 | })) |
| 473 | } |
| 474 | |
| 475 | #[cfg(not(feature = "arbitrary_precision"))] |
| 476 | { |
| 477 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer# { |
| 478 | py: self.py, |
| 479 | builder: P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::builder(self.py, len, name)?, |
| 480 | _types: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 481 | }) |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | fn serialize_struct_variantrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][Serializer]serialize_struct_variant().( |
| 486 | self, |
| 487 | name: &'static str, |
| 488 | _variant_index: u32, |
| 489 | variant: &'static str, |
| 490 | len: usize, |
| 491 | ) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<PythonStructVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#<'py, P>> { |
| 492 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PythonStructVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer# { |
| 493 | namerust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#name., |
| 494 | variantrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#variant., |
| 495 | innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner.: PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer# { |
| 496 | pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py.: self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., |
| 497 | builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder.: P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#builder().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#py., len, variant)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 498 | _typesrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#_types.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 499 | }, |
| 500 | }) |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeSeqrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq# for PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P> { |
| 505 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 506 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 507 | |
| 508 | fn serialize_elementrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]serialize_element().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 509 | where |
| 510 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 511 | { |
| 512 | self.itemsrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#items..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pythonize_customrust-analyzer cargo pythonize 0.28.0 ser/pythonize_custom().::<P, _>(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py., value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 513 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 514 | } |
| 515 | |
| 516 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 517 | let instance = P::Listrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#List#::create_sequencerust-analyzer cargo pythonize 0.28.0 ser/PythonizeListType#create_sequence().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py., self.itemsrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#items.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 518 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(instance.into_pyobjectrust-analyzer cargo pyo3 0.28.1 conversion/impl#[`Bound<'py, T>`][`IntoPyObject<'py>`]into_pyobject().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeTuplerust-analyzer cargo serde_core 1.0.228 ser/SerializeTuple# for PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P> { |
| 523 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTuple]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 524 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTuple]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 525 | |
| 526 | fn serialize_elementrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTuple]serialize_element().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 527 | where |
| 528 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 529 | { |
| 530 | serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeSeqrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq#::serialize_elementrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]serialize_element().(self, value) |
| 531 | } |
| 532 | |
| 533 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTuple]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 534 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyTuplerust-analyzer cargo pyo3 0.28.1 types/tuple/PyTuple#::newrust-analyzer cargo pyo3 0.28.1 types/tuple/impl#[PyTuple]new().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py., self.itemsrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#items.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeTupleStructrust-analyzer cargo serde_core 1.0.228 ser/SerializeTupleStruct# for PythonCollectionSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#<'py, P> { |
| 539 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTupleStruct]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 540 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTupleStruct]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 541 | |
| 542 | fn serialize_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTupleStruct]serialize_field().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 543 | where |
| 544 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 545 | { |
| 546 | serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeSeqrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq#::serialize_elementrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]serialize_element().(self, value) |
| 547 | } |
| 548 | |
| 549 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTupleStruct]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 550 | serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeTuplerust-analyzer cargo serde_core 1.0.228 ser/SerializeTuple#::endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTuple]end().(self) |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeTupleVariantrust-analyzer cargo serde_core 1.0.228 ser/SerializeTupleVariant# for PythonTupleVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#<'py, P> { |
| 555 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonTupleVariantSerializer<'py, P>`][SerializeTupleVariant]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 556 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonTupleVariantSerializer<'py, P>`][SerializeTupleVariant]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 557 | |
| 558 | fn serialize_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonTupleVariantSerializer<'py, P>`][SerializeTupleVariant]serialize_field().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 559 | where |
| 560 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 561 | { |
| 562 | serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeSeqrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq#::serialize_elementrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeSeq]serialize_element().(&mut self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#inner., value) |
| 563 | } |
| 564 | |
| 565 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonTupleVariantSerializer<'py, P>`][SerializeTupleVariant]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 566 | let mut m = P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#builder().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#inner..pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py., 1, self.namerust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#name.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 567 | P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::push_fieldrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#push_field().( |
| 568 | &mut m, |
| 569 | PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#::newrust-analyzer cargo pyo3 0.28.1 types/string/impl#[PyString]new().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#inner..pyrust-analyzer cargo pythonize 0.28.0 ser/PythonCollectionSerializer#py., self.variantrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#variant.), |
| 570 | serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeTuplerust-analyzer cargo serde_core 1.0.228 ser/SerializeTuple#::endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonCollectionSerializer<'py, P>`][SerializeTuple]end().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonTupleVariantSerializer#inner.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 571 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 572 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#finish().(m)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeMaprust-analyzer cargo serde_core 1.0.228 ser/SerializeMap# for PythonMapSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#<'py, P> { |
| 577 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonMapSerializer<'py, P>`][SerializeMap]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 578 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonMapSerializer<'py, P>`][SerializeMap]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 579 | |
| 580 | fn serialize_keyrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonMapSerializer<'py, P>`][SerializeMap]serialize_key().<T>(&mut self, key: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 581 | where |
| 582 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 583 | { |
| 584 | self.keyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#key. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pythonize_customrust-analyzer cargo pythonize 0.28.0 ser/pythonize_custom().::<P, _>(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#py., key)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 585 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 586 | } |
| 587 | |
| 588 | fn serialize_valuerust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonMapSerializer<'py, P>`][SerializeMap]serialize_value().<T>(&mut self, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 589 | where |
| 590 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 591 | { |
| 592 | P::Maprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#Map#::push_itemrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#push_item().( |
| 593 | &mut self.builderrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#builder., |
| 594 | self.keyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#key. |
| 595 | .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() |
| 596 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("serialize_value should always be called after serialize_key"), |
| 597 | pythonize_customrust-analyzer cargo pythonize 0.28.0 ser/pythonize_custom().::<P, _>(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#py., value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 598 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 599 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 600 | } |
| 601 | |
| 602 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonMapSerializer<'py, P>`][SerializeMap]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 603 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(P::Maprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#Map#::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeMappingType#finish().(self.builderrust-analyzer cargo pythonize 0.28.0 ser/PythonMapSerializer#builder.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | #[cfg(feature = "arbitrary_precision")] |
| 608 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeStructrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct# for StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#<'py, P> { |
| 609 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`StructSerializer<'py, P>`][SerializeStruct]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 610 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`StructSerializer<'py, P>`][SerializeStruct]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 611 | |
| 612 | fn serialize_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`StructSerializer<'py, P>`][SerializeStruct]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 613 | where |
| 614 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 615 | { |
| 616 | match self { |
| 617 | StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Structrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Struct#(s) => s.serialize_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructDictSerializer<'py, P>`][SerializeStruct]serialize_field().(key, value), |
| 618 | StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Numberrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number# { number_stringrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#number_string., .. } => { |
| 619 | let serde_jsonrust-analyzer cargo serde_json 1.0.149 crate/::Valuerust-analyzer cargo serde_json 1.0.149 value/Value#::Stringrust-analyzer cargo serde_json 1.0.149 value/Value#String#(s) = value |
| 620 | .serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#serialize().(serde_jsonrust-analyzer cargo serde_json 1.0.149 crate/::valuerust-analyzer cargo serde_json 1.0.149 value/::Serializerrust-analyzer cargo serde_json 1.0.149 value/ser/Serializer#) |
| 621 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| { |
| 622 | PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#::msgrust-analyzer cargo pythonize 0.28.0 error/impl#[PythonizeError]msg().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Failed to serialize number: {}", e)) |
| 623 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 624 | else { |
| 625 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#::msgrust-analyzer cargo pythonize 0.28.0 error/impl#[PythonizeError]msg().("Expected string in serde_json::Number")); |
| 626 | }; |
| 627 | |
| 628 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().number_string = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s); |
| 629 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`StructSerializer<'py, P>`][SerializeStruct]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 635 | match self { |
| 636 | StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Structrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Struct#(s) => s.endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructDictSerializer<'py, P>`][SerializeStruct]end().(), |
| 637 | StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Numberrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number# { |
| 638 | pyrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#py., |
| 639 | number_stringrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number#number_string.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s), |
| 640 | .. |
| 641 | } => { |
| 642 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(i) = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<i64>() { |
| 643 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyIntrust-analyzer cargo pyo3 0.28.1 types/num/PyInt#::newrust-analyzer cargo pyo3 0.28.1 types/num/impl#[PyInt]new().(py, i).into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()); |
| 644 | } |
| 645 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(u) = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<u64>() { |
| 646 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyIntrust-analyzer cargo pyo3 0.28.1 types/num/PyInt#::newrust-analyzer cargo pyo3 0.28.1 types/num/impl#[PyInt]new().(py, u).into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()); |
| 647 | } |
| 648 | if s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'.' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'e' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'E') { |
| 649 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(f) = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<f64>() { |
| 650 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PyFloatrust-analyzer cargo pyo3 0.28.1 types/float/PyFloat#::newrust-analyzer cargo pyo3 0.28.1 types/float/impl#[PyFloat]new().(py, f).into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()); |
| 651 | } |
| 652 | } |
| 653 | // Fall back to Python's int() constructor, which supports arbitrary precision. |
| 654 | py.get_typerust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'py>`]get_type().::<PyIntrust-analyzer cargo pyo3 0.28.1 types/num/PyInt#>() |
| 655 | .call1rust-analyzer cargo pyo3 0.28.1 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call1().((s.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(),)) |
| 656 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#::msgrust-analyzer cargo pythonize 0.28.0 error/impl#[PythonizeError]msg().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid number: {}", e))) |
| 657 | } |
| 658 | StructSerializerrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#::Numberrust-analyzer cargo pythonize 0.28.0 ser/StructSerializer#Number# { .. } => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#::msgrust-analyzer cargo pythonize 0.28.0 error/impl#[PythonizeError]msg().("Empty serde_json::Number")), |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeStructrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct# for PythonStructDictSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#<'py, P> { |
| 664 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructDictSerializer<'py, P>`][SerializeStruct]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 665 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructDictSerializer<'py, P>`][SerializeStruct]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 666 | |
| 667 | fn serialize_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructDictSerializer<'py, P>`][SerializeStruct]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 668 | where |
| 669 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 670 | { |
| 671 | P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::push_fieldrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#push_field().( |
| 672 | &mut self.builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder., |
| 673 | PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#::newrust-analyzer cargo pyo3 0.28.1 types/string/impl#[PyString]new().(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py., key), |
| 674 | pythonize_customrust-analyzer cargo pythonize 0.28.0 ser/pythonize_custom().::<P, _>(self.pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py., value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 675 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 676 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 677 | } |
| 678 | |
| 679 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructDictSerializer<'py, P>`][SerializeStruct]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 680 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#finish().(self.builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | impl<'py, P: PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#> serrust-analyzer cargo serde_core 1.0.228 ser/::SerializeStructVariantrust-analyzer cargo serde_core 1.0.228 ser/SerializeStructVariant# for PythonStructVariantSerializerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#<'py, P> { |
| 685 | type Okrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructVariantSerializer<'py, P>`][SerializeStructVariant]Ok# = Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>; |
| 686 | type Errorrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructVariantSerializer<'py, P>`][SerializeStructVariant]Error# = PythonizeErrorrust-analyzer cargo pythonize 0.28.0 error/PythonizeError#; |
| 687 | |
| 688 | fn serialize_fieldrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructVariantSerializer<'py, P>`][SerializeStructVariant]serialize_field().<T>(&mut self, key: &'static str, value: &T) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<()> |
| 689 | where |
| 690 | T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 691 | { |
| 692 | P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::push_fieldrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#push_field().( |
| 693 | &mut self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner..builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder., |
| 694 | PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#::newrust-analyzer cargo pyo3 0.28.1 types/string/impl#[PyString]new().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner..pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py., key), |
| 695 | pythonize_customrust-analyzer cargo pythonize 0.28.0 ser/pythonize_custom().::<P, _>(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner..pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py., value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 696 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 697 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 698 | } |
| 699 | |
| 700 | fn endrust-analyzer cargo pythonize 0.28.0 ser/impl#[`PythonStructVariantSerializer<'py, P>`][SerializeStructVariant]end().(self) -> Resultrust-analyzer cargo pythonize 0.28.0 error/Result#<Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'py, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#>> { |
| 701 | let v = P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#finish().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner..builderrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#builder.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 702 | let mut m = P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::builderrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#builder().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner..pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py., 1, self.namerust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#name.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 703 | P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::push_fieldrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#push_field().( |
| 704 | &mut m, |
| 705 | PyStringrust-analyzer cargo pyo3 0.28.1 types/string/PyString#::newrust-analyzer cargo pyo3 0.28.1 types/string/impl#[PyString]new().(self.innerrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#inner..pyrust-analyzer cargo pythonize 0.28.0 ser/PythonStructDictSerializer#py., self.variantrust-analyzer cargo pythonize 0.28.0 ser/PythonStructVariantSerializer#variant.), |
| 706 | v.into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().(), |
| 707 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 708 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(P::NamedMaprust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#NamedMap#::finishrust-analyzer cargo pythonize 0.28.0 ser/PythonizeNamedMappingType#finish().(m)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..into_anyrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]into_any().()) |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | #[cfg(test)] |
| 713 | mod testrust-analyzer cargo pythonize 0.28.0 ser/test/ { |
| 714 | use superrust-analyzer cargo pythonize 0.28.0 ser/::pythonizerust-analyzer cargo pythonize 0.28.0 ser/pythonize().; |
| 715 | use maplitrust-analyzer cargo maplit 1.0.2 crate/::hashmaprust-analyzer cargo maplit 1.0.2 hashmap!; |
| 716 | use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::preluderust-analyzer cargo pyo3 0.28.1 prelude/::*; |
| 717 | use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::pybackedrust-analyzer cargo pyo3 0.28.1 pybacked/::PyBackedStrrust-analyzer cargo pyo3 0.28.1 pybacked/PyBackedStr#; |
| 718 | use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::typesrust-analyzer cargo pyo3 0.28.1 types/::{PyBytesrust-analyzer cargo pyo3 0.28.1 types/bytes/PyBytes#, PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#}; |
| 719 | use serderust-analyzer cargo serde 1.0.228 crate/::Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#; |
| 720 | |
| 721 | fn test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().<T>(src: T, expected: &str) |
| 722 | where |
| 723 | T: Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 724 | { |
| 725 | Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#::attachrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'_>`]attach().(|py| -> PyResultrust-analyzer cargo pyo3 0.28.1 err/PyResult#<()> { |
| 726 | let obj = pythonizerust-analyzer cargo pythonize 0.28.0 ser/pythonize().(py, &src)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 727 | |
| 728 | let locals = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py); |
| 729 | locals.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("obj", obj)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 730 | |
| 731 | py.runrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'py>`]run().( |
| 732 | c"import json; result = json.dumps(obj, separators=(',', ':'))", |
| 733 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 734 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&locals), |
| 735 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 736 | let result = locals.get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("result")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 737 | let result = result.extractrust-analyzer cargo pyo3 0.28.1 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().::<PyBackedStrrust-analyzer cargo pyo3 0.28.1 pybacked/PyBackedStr#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 738 | |
| 739 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, expected); |
| 740 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serde_jsonrust-analyzer cargo serde_json 1.0.149 crate/::to_stringrust-analyzer cargo serde_json 1.0.149 ser/to_string().(&src).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), expected); |
| 741 | |
| 742 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 743 | }) |
| 744 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 745 | } |
| 746 | |
| 747 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 748 | fn test_empty_structrust-analyzer cargo pythonize 0.28.0 ser/test/test_empty_struct().() { |
| 749 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 750 | struct Emptyrust-analyzer cargo pythonize 0.28.0 ser/test/Empty#; |
| 751 | |
| 752 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Emptyrust-analyzer cargo pythonize 0.28.0 ser/test/Empty#, "null"); |
| 753 | } |
| 754 | |
| 755 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 756 | fn test_structrust-analyzer cargo pythonize 0.28.0 ser/test/test_struct().() { |
| 757 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 758 | struct Structrust-analyzer cargo pythonize 0.28.0 ser/test/Struct# { |
| 759 | foorust-analyzer cargo pythonize 0.28.0 ser/test/Struct#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 760 | barrust-analyzer cargo pythonize 0.28.0 ser/test/Struct#bar.: usize, |
| 761 | } |
| 762 | |
| 763 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().( |
| 764 | Structrust-analyzer cargo pythonize 0.28.0 ser/test/Struct# { |
| 765 | foorust-analyzer cargo pythonize 0.28.0 ser/test/Struct#foo.: "foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 766 | barrust-analyzer cargo pythonize 0.28.0 ser/test/Struct#bar.: 5, |
| 767 | }, |
| 768 | r#"{"foo":"foo","bar":5}"#, |
| 769 | ); |
| 770 | } |
| 771 | |
| 772 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 773 | fn test_nested_structrust-analyzer cargo pythonize 0.28.0 ser/test/test_nested_struct().() { |
| 774 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 775 | struct Foorust-analyzer cargo pythonize 0.28.0 ser/test/Foo# { |
| 776 | namerust-analyzer cargo pythonize 0.28.0 ser/test/Foo#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 777 | barrust-analyzer cargo pythonize 0.28.0 ser/test/Foo#bar.: Barrust-analyzer cargo pythonize 0.28.0 ser/test/Bar#, |
| 778 | } |
| 779 | |
| 780 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 781 | struct Barrust-analyzer cargo pythonize 0.28.0 ser/test/Bar# { |
| 782 | namerust-analyzer cargo pythonize 0.28.0 ser/test/Bar#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 783 | } |
| 784 | |
| 785 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().( |
| 786 | Foorust-analyzer cargo pythonize 0.28.0 ser/test/Foo# { |
| 787 | namerust-analyzer cargo pythonize 0.28.0 ser/test/Foo#name.: "foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 788 | barrust-analyzer cargo pythonize 0.28.0 ser/test/Foo#bar.: Barrust-analyzer cargo pythonize 0.28.0 ser/test/Bar# { |
| 789 | namerust-analyzer cargo pythonize 0.28.0 ser/test/Bar#name.: "bar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 790 | }, |
| 791 | }, |
| 792 | r#"{"name":"foo","bar":{"name":"bar"}}"#, |
| 793 | ) |
| 794 | } |
| 795 | |
| 796 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 797 | fn test_tuple_structrust-analyzer cargo pythonize 0.28.0 ser/test/test_tuple_struct().() { |
| 798 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 799 | struct TupleStructrust-analyzer cargo pythonize 0.28.0 ser/test/TupleStruct#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, usize); |
| 800 | |
| 801 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(TupleStructrust-analyzer cargo pythonize 0.28.0 ser/test/TupleStruct#("foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), 5), r#"["foo",5]"#); |
| 802 | } |
| 803 | |
| 804 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 805 | fn test_tuplerust-analyzer cargo pythonize 0.28.0 ser/test/test_tuple().() { |
| 806 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(("foo", 5), r#"["foo",5]"#); |
| 807 | } |
| 808 | |
| 809 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 810 | fn test_vecrust-analyzer cargo pythonize 0.28.0 ser/test/test_vec().() { |
| 811 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3], r#"[1,2,3]"#); |
| 812 | } |
| 813 | |
| 814 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 815 | fn test_maprust-analyzer cargo pythonize 0.28.0 ser/test/test_map().() { |
| 816 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(hashmaprust-analyzer cargo maplit 1.0.2 hashmap!! {"foo" => "foo"}, r#"{"foo":"foo"}"#); |
| 817 | } |
| 818 | |
| 819 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 820 | fn test_enum_unit_variantrust-analyzer cargo pythonize 0.28.0 ser/test/test_enum_unit_variant().() { |
| 821 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 822 | enum Erust-analyzer cargo pythonize 0.28.0 ser/test/E# { |
| 823 | Emptyrust-analyzer cargo pythonize 0.28.0 ser/test/E#Empty#, |
| 824 | } |
| 825 | |
| 826 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Erust-analyzer cargo pythonize 0.28.0 ser/test/E#::Emptyrust-analyzer cargo pythonize 0.28.0 ser/test/E#Empty#, r#""Empty""#); |
| 827 | } |
| 828 | |
| 829 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 830 | fn test_enum_tuple_variantrust-analyzer cargo pythonize 0.28.0 ser/test/test_enum_tuple_variant().() { |
| 831 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 832 | enum Erust-analyzer cargo pythonize 0.28.0 ser/test/E# { |
| 833 | Tuplerust-analyzer cargo pythonize 0.28.0 ser/test/E#Tuple#(i32, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 834 | } |
| 835 | |
| 836 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Erust-analyzer cargo pythonize 0.28.0 ser/test/E#::Tuplerust-analyzer cargo pythonize 0.28.0 ser/test/E#Tuple#(5, "foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), r#"{"Tuple":[5,"foo"]}"#); |
| 837 | } |
| 838 | |
| 839 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 840 | fn test_enum_newtype_variantrust-analyzer cargo pythonize 0.28.0 ser/test/test_enum_newtype_variant().() { |
| 841 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 842 | enum Erust-analyzer cargo pythonize 0.28.0 ser/test/E# { |
| 843 | NewTyperust-analyzer cargo pythonize 0.28.0 ser/test/E#NewType#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 844 | } |
| 845 | |
| 846 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Erust-analyzer cargo pythonize 0.28.0 ser/test/E#::NewTyperust-analyzer cargo pythonize 0.28.0 ser/test/E#NewType#("foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), r#"{"NewType":"foo"}"#); |
| 847 | } |
| 848 | |
| 849 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 850 | fn test_enum_struct_variantrust-analyzer cargo pythonize 0.28.0 ser/test/test_enum_struct_variant().() { |
| 851 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 852 | enum Erust-analyzer cargo pythonize 0.28.0 ser/test/E# { |
| 853 | Structrust-analyzer cargo pythonize 0.28.0 ser/test/E#Struct# { foorust-analyzer cargo pythonize 0.28.0 ser/test/E#Struct#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, barrust-analyzer cargo pythonize 0.28.0 ser/test/E#Struct#bar.: usize }, |
| 854 | } |
| 855 | |
| 856 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().( |
| 857 | Erust-analyzer cargo pythonize 0.28.0 ser/test/E#::Structrust-analyzer cargo pythonize 0.28.0 ser/test/E#Struct# { |
| 858 | foorust-analyzer cargo pythonize 0.28.0 ser/test/E#Struct#foo.: "foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 859 | barrust-analyzer cargo pythonize 0.28.0 ser/test/E#Struct#bar.: 5, |
| 860 | }, |
| 861 | r#"{"Struct":{"foo":"foo","bar":5}}"#, |
| 862 | ); |
| 863 | } |
| 864 | |
| 865 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 866 | fn test_integersrust-analyzer cargo pythonize 0.28.0 ser/test/test_integers().() { |
| 867 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 868 | struct Integersrust-analyzer cargo pythonize 0.28.0 ser/test/Integers# { |
| 869 | arust-analyzer cargo pythonize 0.28.0 ser/test/Integers#a.: i8, |
| 870 | brust-analyzer cargo pythonize 0.28.0 ser/test/Integers#b.: i16, |
| 871 | crust-analyzer cargo pythonize 0.28.0 ser/test/Integers#c.: i32, |
| 872 | drust-analyzer cargo pythonize 0.28.0 ser/test/Integers#d.: i64, |
| 873 | erust-analyzer cargo pythonize 0.28.0 ser/test/Integers#e.: u8, |
| 874 | frust-analyzer cargo pythonize 0.28.0 ser/test/Integers#f.: u16, |
| 875 | grust-analyzer cargo pythonize 0.28.0 ser/test/Integers#g.: u32, |
| 876 | hrust-analyzer cargo pythonize 0.28.0 ser/test/Integers#h.: u64, |
| 877 | } |
| 878 | |
| 879 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().( |
| 880 | Integersrust-analyzer cargo pythonize 0.28.0 ser/test/Integers# { |
| 881 | arust-analyzer cargo pythonize 0.28.0 ser/test/Integers#a.: 1, |
| 882 | brust-analyzer cargo pythonize 0.28.0 ser/test/Integers#b.: 2, |
| 883 | crust-analyzer cargo pythonize 0.28.0 ser/test/Integers#c.: 3, |
| 884 | drust-analyzer cargo pythonize 0.28.0 ser/test/Integers#d.: 4, |
| 885 | erust-analyzer cargo pythonize 0.28.0 ser/test/Integers#e.: 5, |
| 886 | frust-analyzer cargo pythonize 0.28.0 ser/test/Integers#f.: 6, |
| 887 | grust-analyzer cargo pythonize 0.28.0 ser/test/Integers#g.: 7, |
| 888 | hrust-analyzer cargo pythonize 0.28.0 ser/test/Integers#h.: 8, |
| 889 | }, |
| 890 | r#"{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8}"#, |
| 891 | ) |
| 892 | } |
| 893 | |
| 894 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 895 | fn test_floatsrust-analyzer cargo pythonize 0.28.0 ser/test/test_floats().() { |
| 896 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 897 | struct Floatsrust-analyzer cargo pythonize 0.28.0 ser/test/Floats# { |
| 898 | arust-analyzer cargo pythonize 0.28.0 ser/test/Floats#a.: f32, |
| 899 | brust-analyzer cargo pythonize 0.28.0 ser/test/Floats#b.: f64, |
| 900 | } |
| 901 | |
| 902 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Floatsrust-analyzer cargo pythonize 0.28.0 ser/test/Floats# { arust-analyzer cargo pythonize 0.28.0 ser/test/Floats#a.: 1.0, brust-analyzer cargo pythonize 0.28.0 ser/test/Floats#b.: 2.0 }, r#"{"a":1.0,"b":2.0}"#) |
| 903 | } |
| 904 | |
| 905 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 906 | fn test_charrust-analyzer cargo pythonize 0.28.0 ser/test/test_char().() { |
| 907 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 908 | struct Charrust-analyzer cargo pythonize 0.28.0 ser/test/Char# { |
| 909 | arust-analyzer cargo pythonize 0.28.0 ser/test/Char#a.: char, |
| 910 | } |
| 911 | |
| 912 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Charrust-analyzer cargo pythonize 0.28.0 ser/test/Char# { arust-analyzer cargo pythonize 0.28.0 ser/test/Char#a.: 'a' }, r#"{"a":"a"}"#) |
| 913 | } |
| 914 | |
| 915 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 916 | fn test_boolrust-analyzer cargo pythonize 0.28.0 ser/test/test_bool().() { |
| 917 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(true, "true"); |
| 918 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(false, "false"); |
| 919 | } |
| 920 | |
| 921 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 922 | fn test_nonerust-analyzer cargo pythonize 0.28.0 ser/test/test_none().() { |
| 923 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 924 | struct Srust-analyzer cargo pythonize 0.28.0 ser/test/S#; |
| 925 | |
| 926 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().((), "null"); |
| 927 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Srust-analyzer cargo pythonize 0.28.0 ser/test/S#, "null"); |
| 928 | |
| 929 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1), "1"); |
| 930 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<i32>, "null"); |
| 931 | } |
| 932 | |
| 933 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 934 | fn test_bytesrust-analyzer cargo pythonize 0.28.0 ser/test/test_bytes().() { |
| 935 | // serde treats &[u8] as a sequence of integers due to lack of specialization |
| 936 | test_serrust-analyzer cargo pythonize 0.28.0 ser/test/test_ser().(b"foo", "[102,111,111]"); |
| 937 | |
| 938 | Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#::attachrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'_>`]attach().(|py| { |
| 939 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pythonizerust-analyzer cargo pythonize 0.28.0 ser/pythonize().(py, serde_bytesrust-analyzer cargo serde_bytes 0.11.19 crate/::Bytesrust-analyzer cargo serde_bytes 0.11.19 bytes/Bytes#::newrust-analyzer cargo serde_bytes 0.11.19 bytes/impl#[Bytes]new().(b"foo")) |
| 940 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("bytes will always serialize successfully") |
| 941 | .eqrust-analyzer cargo pyo3 0.28.1 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]eq().(&PyBytesrust-analyzer cargo pyo3 0.28.1 types/bytes/PyBytes#::newrust-analyzer cargo pyo3 0.28.1 types/bytes/impl#[PyBytes]new().(py, b"foo")) |
| 942 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("bytes will always compare successfully")); |
| 943 | }); |
| 944 | } |
| 945 | } |