aboutsummaryrefslogtreecommitdiff
path: root/src/data/maybe_serializable_data.rs
blob: db389632ec2b434430abac00c85c0ca68f3e2706 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use downcast_rs::{impl_downcast, DowncastSync};
#[cfg(feature = "serde-serialize")]
use erased_serde::Serialize;

/// Piece of data that may be serializable.
pub trait MaybeSerializableData: DowncastSync {
    /// Convert this shape as a serializable entity.
    #[cfg(feature = "serde-serialize")]
    fn as_serialize(&self) -> Option<(u32, &dyn Serialize)> {
        None
    }
}

impl_downcast!(sync MaybeSerializableData);