Trait migrate_state::StateClient[][src]

pub trait StateClient {
    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
;
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>. The 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 the stored bytes in the storage.

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

Puts the 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 the storage with the given bytes, and if fetch() was called before the intialization hapenned, then fetch() should return Ok(None).

Implementors