apache_avro/
bytes.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! Deprecated. Use [`apache_avro::serde::*`] instead.
19//!
20//! [`apache_avro::serde::*`](crate::serde)
21
22#[cfg(doc)]
23use crate as apache_avro;
24
25/// Deprecated. Use [`apache_avro::serde::bytes`] instead.
26#[deprecated(since = "0.22.0", note = "Use `apache_avro::serde::bytes` instead")]
27pub mod serde_avro_bytes {
28    #[cfg(doc)]
29    use crate as apache_avro;
30    use serde::{Deserializer, Serializer};
31
32    /// Deprecated. Use [`apache_avro::serde::bytes::serialize`] instead.
33    #[deprecated(
34        since = "0.22.0",
35        note = "Use `apache_avro::serde::bytes::serialize` instead"
36    )]
37    pub fn serialize<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
38    where
39        S: Serializer,
40    {
41        crate::serde::bytes::serialize(bytes, serializer)
42    }
43
44    /// Deprecated. Use [`apache_avro::serde::bytes::deserialize`] instead.
45    #[deprecated(
46        since = "0.22.0",
47        note = "Use `apache_avro::serde::bytes::deserialize` instead"
48    )]
49    pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
50    where
51        D: Deserializer<'de>,
52    {
53        crate::serde::bytes::deserialize(deserializer)
54    }
55}
56
57/// Deprecated. Use [`apache_avro::serde::bytes_opt`] instead.
58///
59/// [`apache_avro::serde::bytes_opt`](crate::serde::bytes_opt)
60#[deprecated(since = "0.22.0", note = "Use `apache_avro::serde::bytes_opt` instead")]
61pub mod serde_avro_bytes_opt {
62    #[cfg(doc)]
63    use crate as apache_avro;
64    use serde::{Deserializer, Serializer};
65    use std::borrow::Borrow;
66
67    /// Deprecated. Use [`apache_avro::serde::bytes_opt::serialize`] instead.
68    #[deprecated(
69        since = "0.22.0",
70        note = "Use `apache_avro::serde::bytes_opt::serialize` instead"
71    )]
72    pub fn serialize<S, B>(bytes: &Option<B>, serializer: S) -> Result<S::Ok, S::Error>
73    where
74        S: Serializer,
75        B: Borrow<[u8]> + serde_bytes::Serialize,
76    {
77        crate::serde::bytes_opt::serialize(bytes, serializer)
78    }
79
80    /// Deprecated. Use [`apache_avro::serde::bytes_opt::deserialize`] instead.
81    #[deprecated(
82        since = "0.22.0",
83        note = "Use `apache_avro::serde::bytes_opt::deserialize` instead"
84    )]
85    pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<u8>>, D::Error>
86    where
87        D: Deserializer<'de>,
88    {
89        crate::serde::bytes_opt::deserialize(deserializer)
90    }
91}
92
93/// Deprecated. Use [`apache_avro::serde::fixed`] instead.
94#[deprecated(since = "0.22.0", note = "Use `apache_avro::serde::fixed` instead")]
95pub mod serde_avro_fixed {
96    #[cfg(doc)]
97    use crate as apache_avro;
98    use serde::{Deserializer, Serializer};
99
100    /// Deprecated. Use [`apache_avro::serde::fixed::serialize`] instead.
101    #[deprecated(
102        since = "0.22.0",
103        note = "Use `apache_avro::serde::fixed::serialize` instead"
104    )]
105    pub fn serialize<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
106    where
107        S: Serializer,
108    {
109        crate::serde::fixed::serialize(bytes, serializer)
110    }
111
112    /// Deprecated. Use [`apache_avro::serde::fixed::deserialize`] instead.
113    #[deprecated(
114        since = "0.22.0",
115        note = "Use `apache_avro::serde::fixed::deserialize` instead"
116    )]
117    pub fn deserialize<'de, D, const N: usize>(deserializer: D) -> Result<[u8; N], D::Error>
118    where
119        D: Deserializer<'de>,
120    {
121        crate::serde::fixed::deserialize(deserializer)
122    }
123}
124
125/// Deprecated. Use [`apache_avro::serde::fixed_opt`] instead.
126#[deprecated(since = "0.22.0", note = "Use `apache_avro::serde::fixed_opt` instead")]
127pub mod serde_avro_fixed_opt {
128    #[cfg(doc)]
129    use crate as apache_avro;
130    use serde::{Deserializer, Serializer};
131    use std::borrow::Borrow;
132
133    /// Deprecated. Use [`apache_avro::serde::fixed_opt::serialize`] instead.
134    #[deprecated(
135        since = "0.22.0",
136        note = "Use `apache_avro::serde::fixed_opt::serialize` instead"
137    )]
138    pub fn serialize<S, B>(bytes: &Option<B>, serializer: S) -> Result<S::Ok, S::Error>
139    where
140        S: Serializer,
141        B: Borrow<[u8]> + serde_bytes::Serialize,
142    {
143        crate::serde::fixed_opt::serialize(bytes, serializer)
144    }
145
146    /// Deprecated. Use [`apache_avro::serde::fixed_opt::deserialize`] instead.
147    #[deprecated(
148        since = "0.22.0",
149        note = "Use `apache_avro::serde::fixed_opt::deserialize` instead"
150    )]
151    pub fn deserialize<'de, D, const N: usize>(deserializer: D) -> Result<Option<[u8; N]>, D::Error>
152    where
153        D: Deserializer<'de>,
154    {
155        crate::serde::fixed_opt::deserialize(deserializer)
156    }
157}
158
159/// Deprecated. Use [`apache_avro::serde::slice`] instead.
160#[deprecated(since = "0.22.0", note = "Use `apache_avro::serde::slice` instead")]
161pub mod serde_avro_slice {
162    #[cfg(doc)]
163    use crate as apache_avro;
164    use serde::{Deserializer, Serializer};
165
166    /// Deprecated. Use [`apache_avro::serde::slice::serialize`] instead.
167    #[deprecated(
168        since = "0.22.0",
169        note = "Use `apache_avro::serde::slice::serialize` instead"
170    )]
171    pub fn serialize<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
172    where
173        S: Serializer,
174    {
175        crate::serde::slice::serialize(bytes, serializer)
176    }
177
178    /// Deprecated. Use [`apache_avro::serde::slice::deserialize`] instead.
179    #[deprecated(
180        since = "0.22.0",
181        note = "Use `apache_avro::serde::slice::deserialize` instead"
182    )]
183    pub fn deserialize<'de, D>(deserializer: D) -> Result<&'de [u8], D::Error>
184    where
185        D: Deserializer<'de>,
186    {
187        crate::serde::slice::deserialize(deserializer)
188    }
189}
190
191/// Deprecated. Use [`apache_avro::serde::slice_opt`] instead.
192#[deprecated(since = "0.22.0", note = "Use `apache_avro::serde::slice_opt` instead")]
193pub mod serde_avro_slice_opt {
194    #[cfg(doc)]
195    use crate as apache_avro;
196    use serde::{Deserializer, Serializer};
197    use std::borrow::Borrow;
198
199    /// Deprecated. Use [`apache_avro::serde::slice_opt::serialize`] instead.
200    #[deprecated(
201        since = "0.22.0",
202        note = "Use `apache_avro::serde::slice_opt::serialize` instead"
203    )]
204    pub fn serialize<S, B>(bytes: &Option<B>, serializer: S) -> Result<S::Ok, S::Error>
205    where
206        S: Serializer,
207        B: Borrow<[u8]> + serde_bytes::Serialize,
208    {
209        crate::serde::slice_opt::serialize(bytes, serializer)
210    }
211
212    /// Deprecated. Use [`apache_avro::serde::slice_opt::deserialize`] instead.
213    #[deprecated(
214        since = "0.22.0",
215        note = "Use `apache_avro::serde::slice_opt::deserialize` instead"
216    )]
217    pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<&'de [u8]>, D::Error>
218    where
219        D: Deserializer<'de>,
220    {
221        crate::serde::slice_opt::deserialize(deserializer)
222    }
223}