Skip to main content

waveless_commons/
serialize_utils.rs

1// Waveless
2// Copyright (C) 2026 Oscar Alvarez Gonzalez
3
4use crate::*;
5
6/// Workaround of <https://github.com/serde-rs/serde/issues/1732> for `bool`
7pub fn should_skip(data: &bool) -> bool {
8    if !BINARY_MODE.with(|var| var.get()) {
9        return *data;
10    }
11    false
12}
13
14/// Workaround of <https://github.com/serde-rs/serde/issues/1732> for `Option<T>`
15pub fn should_skip_option<T>(data: &Option<T>) -> bool {
16    if !BINARY_MODE.with(|var| var.get()) {
17        if data.is_none() {
18            return true;
19        }
20    }
21    false
22}
23
24/// Workaround of <https://github.com/serde-rs/serde/issues/1732> for `CheapVec<T>`
25pub fn should_skip_cheapvec<T>(data: &CheapVec<T>) -> bool {
26    if !BINARY_MODE.with(|var| var.get()) {
27        if data.is_empty() {
28            return true;
29        }
30    }
31    false
32}