osom_lib_arrays/serde_impl/fixed_array.rs
1//! NOTE: [`FixedArray`] has to have capacity specified at runtime. This means
2//! that deserialization is not really possible. Even though serde does provide
3//! `size_hint()` at runtime, these are not reliable, and depending on the protocol
4//! will fail to work. For example `serde_json` does not provide those hints.
5//!
6//! For that reason it is better not to implement `Deserialize` and let the
7//! caller handle it manually if needed.
8
9use serde::Serialize;
10
11use osom_lib_alloc::traits::Allocator;
12
13use crate::fixed_array::FixedArray;
14
15impl<T: Serialize, TAllocator: Allocator> Serialize for FixedArray<T, TAllocator> {
16 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
17 where
18 S: serde::Serializer,
19 {
20 self.as_ref().serialize(serializer)
21 }
22}