[][src]Trait xaynet_server::storage::traits::ModelStorage

pub trait ModelStorage where
    Self: Clone + Send + Sync + 'static, 
{ #[must_use] pub fn set_global_model<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        round_id: u64,
        round_seed: &'life1 RoundSeed,
        global_model: &'life2 Model
    ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn global_model<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        id: &'life1 str
    ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Model>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn is_ready<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; pub fn create_global_model_id(
        round_id: u64,
        round_seed: &RoundSeed
    ) -> String { ... } }

An abstract model storage.

Required methods

#[must_use]pub fn set_global_model<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 mut self,
    round_id: u64,
    round_seed: &'life1 RoundSeed,
    global_model: &'life2 Model
) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Sets a global model.

Behavior

  • If the global model already exists (has the same model id), return StorageResult::Err(StorageError)).
  • If the global model does not exist, set the model and return StorageResult::Ok(String)

#[must_use]pub fn global_model<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    id: &'life1 str
) -> Pin<Box<dyn Future<Output = StorageResult<Option<Model>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Returns a global model.

Behavior

  • If the global model does not exist, return StorageResult::Ok(Option::None).
  • If the global model exists, return StorageResult::Ok(Option::Some(Model)).

#[must_use]pub fn is_ready<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Checks if the ModelStorage is ready to process requests.

Behavior

If the ModelStorage is ready to process requests, return StorageResult::Ok(()). If the ModelStorage cannot process requests because of a connection error, for example, return StorageResult::Err(error).

Loading content...

Provided methods

pub fn create_global_model_id(round_id: u64, round_seed: &RoundSeed) -> String[src]

Creates a unique global model id by using the round id and the round seed in which the global model was created.

The format of the default implementation is roundid_roundseed, where the RoundSeed is encoded in hexadecimal.

Loading content...

Implementors

impl ModelStorage for NoOp[src]

impl ModelStorage for Client[src]

This is supported on crate feature model-persistence only.

impl<C, M> ModelStorage for Store<C, M> where
    C: CoordinatorStorage,
    M: ModelStorage
[src]

Loading content...