pub struct InMemoryRepository { /* private fields */ }Expand description
In-memory migration repository for testing
Provides a simple implementation of MigrationRepository that stores migrations
in memory using a HashMap. Useful for testing migration persistence without
actual file I/O.
§Examples
// #[tokio::test]
// async fn test_repository() {
let mut repo = InMemoryRepository::new();
let migration = Migration::new("0001_initial", "polls");
repo.save(&migration).await.unwrap();
let retrieved = repo.get("polls", "0001_initial").await.unwrap();
assert_eq!(retrieved.name, "0001_initial");
// }Implementations§
Source§impl InMemoryRepository
impl InMemoryRepository
Sourcepub fn with_migrations(migrations: Vec<Migration>) -> Self
pub fn with_migrations(migrations: Vec<Migration>) -> Self
Create an InMemoryRepository with initial migrations
Trait Implementations§
Source§impl Default for InMemoryRepository
impl Default for InMemoryRepository
Source§impl MigrationRepository for InMemoryRepository
impl MigrationRepository for InMemoryRepository
Source§fn save<'life0, 'life1, 'async_trait>(
&'life0 mut self,
migration: &'life1 Migration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 mut self,
migration: &'life1 Migration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Saves a migration to the repository
Source§fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Migration>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Migration>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Retrieves a migration by app and name
Source§fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Lists all migrations for an app
Source§fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Deletes a migration (optional, not all repositories support this)
Source§fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, MigrationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, MigrationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Checks if a migration exists
Auto Trait Implementations§
impl Freeze for InMemoryRepository
impl RefUnwindSafe for InMemoryRepository
impl Send for InMemoryRepository
impl Sync for InMemoryRepository
impl Unpin for InMemoryRepository
impl UnsafeUnpin for InMemoryRepository
impl UnwindSafe for InMemoryRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().