Skip to main content

toasty_driver_integration_suite/scenarios/
person_contact_deferred_metadata.rs

1use crate::prelude::*;
2
3scenario! {
4    #[derive(Debug, toasty::Model)]
5    struct Person {
6        #[key]
7        #[auto]
8        id: uuid::Uuid,
9
10        name: String,
11
12        contact: ContactInfo,
13    }
14
15    #[derive(Debug, toasty::Embed)]
16    enum ContactInfo {
17        Email { address: String, metadata: Metadata },
18        Phone { number: String },
19    }
20
21    #[derive(Debug, toasty::Embed)]
22    struct Metadata {
23        author: String,
24        notes: toasty::Deferred<String>,
25    }
26
27    async fn setup(test: &mut Test) -> toasty::Db {
28        test.setup_db(models!(Person)).await
29    }
30}