Trait migrate_state::StateClient[][src]

pub trait StateClient {
    #[must_use]
    fn fetch<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn update<'life0, 'async_trait>(
        &'life0 mut self,
        state: Vec<u8>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; }
Expand description

Client for the migration state storage.

State storage is basically a Vec<u8>. Implementations of this trait should not make any assumptions about the state shape (i.e. what the given Vec<u8> represents). The given bytes are not even guaranteed to be valid UTF8.

Required methods

Return all bytes stored in the storage.

If the storage wasn’t initialized yet with update() call previously then it should return Ok(vec![]) (empty vector), otherwise value stored with the most recent update() call should be returned

Puts given bytes into the storage.

It shouldn’t make any assumptions about what these bytes represent, there are no guarantees about the byte pattern migrate uses to store the serialized migration state representation.

For the first ever call to update() it should initialize storage with the given bytes, and if fetch() was called before intialization hapenned, then fetch() should return Ok(None).

Implementors