use serde::{Deserialize, Serialize}; use vorm::{AsDocument, FromDocument}; /// Example data model. #[derive(Clone, Debug, Deserialize, Serialize)] struct Character { name: String, gender: Option, age: u64, in_chapters: Vec, likes_tea: bool, } impl AsDocument for Character {} impl FromDocument for Character {} impl PartialEq for Character { fn eq(&self, other: &Self) -> bool { self.name == other.name && self.gender == other.gender && self.age == other.age && self.in_chapters == other.in_chapters && self.likes_tea == other.likes_tea } } #[tokio::test] async fn asplusfrom() { let ghost = Character { name: "Ghost".to_owned(), gender: None, age: 546981857453, in_chapters: vec![1, 2, 43, 98, 100], likes_tea: true }; assert_eq!(Character::from_doc(ghost.as_doc().unwrap()).unwrap(), ghost); }