pub struct VbrEngine { /* private fields */ }Expand description
Main VBR engine
Implementations§
Source§impl VbrEngine
impl VbrEngine
Sourcepub async fn new(config: VbrConfig) -> Result<Self>
pub async fn new(config: VbrConfig) -> Result<Self>
Create a new VBR engine with the given configuration
Sourcepub fn database_arc(&self) -> Arc<dyn VirtualDatabase + Send + Sync>
pub fn database_arc(&self) -> Arc<dyn VirtualDatabase + Send + Sync>
Get the virtual database as Arc for sharing
Sourcepub fn database(&self) -> &dyn VirtualDatabase
pub fn database(&self) -> &dyn VirtualDatabase
Get a reference to the virtual database
Sourcepub fn registry(&self) -> &EntityRegistry
pub fn registry(&self) -> &EntityRegistry
Get the entity registry
Sourcepub fn registry_mut(&mut self) -> &mut EntityRegistry
pub fn registry_mut(&mut self) -> &mut EntityRegistry
Get mutable access to the entity registry
Sourcepub async fn from_openapi(
config: VbrConfig,
openapi_content: &str,
) -> Result<(Self, OpenApiConversionResult)>
pub async fn from_openapi( config: VbrConfig, openapi_content: &str, ) -> Result<(Self, OpenApiConversionResult)>
Create VBR engine from an OpenAPI specification
This method automatically:
- Parses the OpenAPI 3.x specification
- Extracts entity schemas from
components/schemas - Auto-detects primary keys and foreign keys
- Registers all entities in the engine
- Creates database tables for all entities
§Arguments
config- VBR configurationopenapi_content- OpenAPI specification content (JSON or YAML)
§Returns
VBR engine with entities registered and database initialized
Sourcepub async fn from_openapi_file<P: AsRef<Path>>(
config: VbrConfig,
file_path: P,
) -> Result<(Self, OpenApiConversionResult)>
pub async fn from_openapi_file<P: AsRef<Path>>( config: VbrConfig, file_path: P, ) -> Result<(Self, OpenApiConversionResult)>
Sourcepub async fn seed_entity(
&self,
entity_name: &str,
records: &[HashMap<String, Value>],
) -> Result<usize>
pub async fn seed_entity( &self, entity_name: &str, records: &[HashMap<String, Value>], ) -> Result<usize>
Seed entity with data
§Arguments
entity_name- Name of the entity to seedrecords- Records to insert
Sourcepub async fn seed_all(
&self,
seed_data: &SeedData,
) -> Result<HashMap<String, usize>>
pub async fn seed_all( &self, seed_data: &SeedData, ) -> Result<HashMap<String, usize>>
Seed all entities with data (respects dependencies)
§Arguments
seed_data- Seed data organized by entity name
Sourcepub async fn seed_from_file<P: AsRef<Path>>(
&self,
file_path: P,
) -> Result<HashMap<String, usize>>
pub async fn seed_from_file<P: AsRef<Path>>( &self, file_path: P, ) -> Result<HashMap<String, usize>>
Sourcepub async fn clear_entity(&self, entity_name: &str) -> Result<()>
pub async fn clear_entity(&self, entity_name: &str) -> Result<()>
Sourcepub async fn create_snapshot<P: AsRef<Path>>(
&self,
name: &str,
description: Option<String>,
snapshots_dir: P,
) -> Result<SnapshotMetadata>
pub async fn create_snapshot<P: AsRef<Path>>( &self, name: &str, description: Option<String>, snapshots_dir: P, ) -> Result<SnapshotMetadata>
Create a snapshot of the current database state
§Arguments
name- Name for the snapshotdescription- Optional descriptionsnapshots_dir- Directory to store snapshots
Sourcepub async fn create_snapshot_with_time_travel<P: AsRef<Path>>(
&self,
name: &str,
description: Option<String>,
snapshots_dir: P,
include_time_travel: bool,
time_travel_state: Option<TimeTravelSnapshotState>,
) -> Result<SnapshotMetadata>
pub async fn create_snapshot_with_time_travel<P: AsRef<Path>>( &self, name: &str, description: Option<String>, snapshots_dir: P, include_time_travel: bool, time_travel_state: Option<TimeTravelSnapshotState>, ) -> Result<SnapshotMetadata>
Create a snapshot with time travel state
§Arguments
name- Name for the snapshotdescription- Optional descriptionsnapshots_dir- Directory to store snapshotsinclude_time_travel- Whether to include time travel statetime_travel_state- Optional time travel state to include
Sourcepub async fn restore_snapshot<P: AsRef<Path>>(
&self,
name: &str,
snapshots_dir: P,
) -> Result<()>
pub async fn restore_snapshot<P: AsRef<Path>>( &self, name: &str, snapshots_dir: P, ) -> Result<()>
Restore a snapshot
§Arguments
name- Name of the snapshot to restoresnapshots_dir- Directory where snapshots are stored
Sourcepub async fn restore_snapshot_with_time_travel<P, F>(
&self,
name: &str,
snapshots_dir: P,
restore_time_travel: bool,
time_travel_restore_callback: Option<F>,
) -> Result<()>
pub async fn restore_snapshot_with_time_travel<P, F>( &self, name: &str, snapshots_dir: P, restore_time_travel: bool, time_travel_restore_callback: Option<F>, ) -> Result<()>
Restore a snapshot with time travel state
§Arguments
name- Name of the snapshot to restoresnapshots_dir- Directory where snapshots are storedrestore_time_travel- Whether to restore time travel statetime_travel_restore_callback- Optional callback to restore time travel state
Sourcepub async fn list_snapshots<P: AsRef<Path>>(
snapshots_dir: P,
) -> Result<Vec<SnapshotMetadata>>
pub async fn list_snapshots<P: AsRef<Path>>( snapshots_dir: P, ) -> Result<Vec<SnapshotMetadata>>
Sourcepub async fn delete_snapshot<P: AsRef<Path>>(
name: &str,
snapshots_dir: P,
) -> Result<()>
pub async fn delete_snapshot<P: AsRef<Path>>( name: &str, snapshots_dir: P, ) -> Result<()>
Delete a snapshot
§Arguments
name- Name of the snapshot to deletesnapshots_dir- Directory where snapshots are stored
Sourcepub async fn export_state(&self) -> Result<Value>
pub async fn export_state(&self) -> Result<Value>
Export the complete database state as JSON
This exports all entity data in a format suitable for snapshots.
Sourcepub async fn import_state(&self, state: Value) -> Result<()>
pub async fn import_state(&self, state: Value) -> Result<()>
Import database state from JSON
This restores entity data from a previous snapshot export.
Sourcepub async fn state_summary(&self) -> String
pub async fn state_summary(&self) -> String
Get a summary of the current state
Trait Implementations§
Source§impl ProtocolStateExporter for VbrEngine
impl ProtocolStateExporter for VbrEngine
Source§fn protocol_name(&self) -> &str
fn protocol_name(&self) -> &str
Source§fn export_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn export_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for VbrEngine
impl !RefUnwindSafe for VbrEngine
impl Send for VbrEngine
impl Sync for VbrEngine
impl Unpin for VbrEngine
impl !UnwindSafe for VbrEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more