mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-27 15:59:21 +00:00
20 lines
517 B
Rust
20 lines
517 B
Rust
|
//! # Legacy API boolean
|
||
|
//!
|
||
|
//! true => 1
|
||
|
//! false => 0
|
||
|
|
||
|
|
||
|
use serde::{Serialize, Serializer};
|
||
|
|
||
|
/// Special implementation of conversation name (false if none / the name otherwise)
|
||
|
pub struct LegacyBool(pub bool);
|
||
|
|
||
|
impl Serialize for LegacyBool {
|
||
|
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
|
||
|
S: Serializer {
|
||
|
match &self.0 {
|
||
|
true => serializer.serialize_i8(1),
|
||
|
false => serializer.serialize_i8(0),
|
||
|
}
|
||
|
}
|
||
|
}
|