lotus_shared/
content.rs

1use serde::{Deserialize, Serialize};
2
3/// A unique identifier for a content item.
4#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, Default)]
5pub struct ContentId {
6    /// The user ID of the content item.
7    pub user_id: i32,
8    /// The sub ID of the content item.
9    pub sub_id: i32,
10}
11
12impl Eq for ContentId {}
13
14impl std::hash::Hash for ContentId {
15    #[inline(always)]
16    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
17        self.user_id.hash(state);
18        self.sub_id.hash(state);
19    }
20}
21
22#[cfg(feature = "ffi")]
23mod ffi {
24    use lotus_script_sys::{FfiObject, FromFfi};
25
26    impl FromFfi for crate::content::ContentId {
27        type FfiType = u64;
28        fn from_ffi(ffi: Self::FfiType) -> Self {
29            FfiObject::from_packed(ffi).deserialize()
30        }
31    }
32}