Trait air_test_utils::prelude::DataStore
pub trait DataStore {
type Error;
// Required methods
fn initialize(&mut self) -> Result<(), Self::Error>;
fn store_data(
&mut self,
data: &[u8],
particle_id: &str,
current_peer_id: &str
) -> Result<(), Self::Error>;
fn read_data(
&mut self,
particle_id: &str,
current_peer_id: &str
) -> Result<Vec<u8, Global>, Self::Error>;
fn cleanup_data(
&mut self,
particle_id: &str,
current_peer_id: &str
) -> Result<(), Self::Error>;
fn detect_anomaly(
&self,
execution_time: Duration,
memory_delta: usize,
outcome: &RawAVMOutcome
) -> bool;
fn collect_anomaly_data(
&mut self,
particle_id: &str,
current_peer_id: &str,
anomaly_data: AnomalyData<'_>
) -> Result<(), Self::Error>;
}
Expand description
This trait is used for
- persisting prev_data between successive calls of an interpreter
- logging previous, current, and new data in case of spikes
Required Associated Types§
type Error
Required Methods§
fn initialize(&mut self) -> Result<(), Self::Error>
fn store_data( &mut self, data: &[u8], particle_id: &str, current_peer_id: &str ) -> Result<(), Self::Error>
fn read_data( &mut self, particle_id: &str, current_peer_id: &str ) -> Result<Vec<u8, Global>, Self::Error>
fn cleanup_data(
&mut self,
particle_id: &str,
current_peer_id: &str
) -> Result<(), Self::Error>
fn cleanup_data( &mut self, particle_id: &str, current_peer_id: &str ) -> Result<(), Self::Error>
Cleanup data that become obsolete.
fn detect_anomaly(
&self,
execution_time: Duration,
memory_delta: usize,
outcome: &RawAVMOutcome
) -> bool
fn detect_anomaly( &self, execution_time: Duration, memory_delta: usize, outcome: &RawAVMOutcome ) -> bool
Returns true if an anomaly happened and it’s necessary to save execution data for debugging purposes. execution_time - time taken by the interpreter to execute provided script memory_delta - count of bytes on which an interpreter heap has been extended during execution of a particle outcome - a result of AquaVM invocation