1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/// A database schema. Part of the MigrationConnector API.
pub struct DatabaseSchema(Box<dyn std::any::Any + Send + Sync>);

impl DatabaseSchema {
    /// Type-erase a migration.
    pub fn new<T: 'static + Send + Sync>(migration: T) -> Self {
        DatabaseSchema(Box::new(migration))
    }

    /// Should never be used in the core, only in connectors that know what they put there.
    pub fn downcast<T: 'static>(self) -> Box<T> {
        self.0.downcast().unwrap()
    }

    /// Should never be used in the core, only in connectors that know what they put there.
    pub fn downcast_ref<T: 'static>(&self) -> &T {
        self.0.downcast_ref().unwrap()
    }
}