/// This will try to read from a snapshot on disk, otherwise load from a local snapshot
/// in memory. Returns the loaded snapshot data, that must be loaded inside the client
/// for access.
This will try to read from a snapshot on disk, otherwise load from a local snapshot
in memory. Returns the loaded snapshot data, that must be loaded inside the client
for access.
This will try to read from a snapshot on disk otherwise load from a local snapshot in memory . Returns the loaded snapshot data that must be loaded inside the client for access .
fn handle(&mut self, msg: messages::ReadFromSnapshot, _ctx: &mut Self::Context) -> Self::Result {
        let id = msg.fid.unwrap_or(msg.id);
        if self.has_data(id) {
            let data = self.get_state(id);
            Ok(ReturnReadSnapshot {
                id,
                data: Box::new(data),
            })
        } else {
            match Snapshot::read_from_snapshot(msg.filename.as_deref(), msg.path.as_deref(), msg.key) {
                Ok(mut snapshot) => {
                    let data = snapshot.get_state(id);
                    *self = snapshot;
                    Ok(ReturnReadSnapshot {
                        id,
                        data: Box::new(data),
                    })
                }
                Err(_) => Err(anyhow::anyhow!(SnapshotError::LoadFailure)),
            }
        }
    }
fn handle ( & mut self , msg : messages :: ReadFromSnapshot , _ctx : & mut Self :: Context ) -> Self :: Result { let id = msg . fid . unwrap_or ( msg . id ) ; if self . has_data ( id ) { let data = self . get_state ( id ) ; Ok ( ReturnReadSnapshot { id , data : Box :: new ( data ) , } ) } else { match Snapshot :: read_from_snapshot ( msg . filename . as_deref ( ) , msg . path . as_deref ( ) , msg . key ) { Ok ( mut snapshot ) => { let data = snapshot . get_state ( id ) ; * self = snapshot ; Ok ( ReturnReadSnapshot { id , data : Box :: new ( data ) , } ) } Err ( _ ) => Err ( anyhow :: anyhow ! ( SnapshotError LoadFailure ) ) , } } }
This will try to read from a snapshot on disk, otherwise load from a local snapshot
in memory.
This will try to read from a snapshot on disk otherwise load from a local snapshot in memory .
&mut self
msg
messages::ReadFromSnapshot
_ctx
&mut Self::Context