VbrEngine

Struct VbrEngine 

Source
pub struct VbrEngine { /* private fields */ }
Expand description

Main VBR engine

Implementations§

Source§

impl VbrEngine

Source

pub async fn new(config: VbrConfig) -> Result<Self>

Create a new VBR engine with the given configuration

Source

pub fn config(&self) -> &VbrConfig

Get the configuration

Source

pub fn database_arc(&self) -> Arc<dyn VirtualDatabase + Send + Sync>

Get the virtual database as Arc for sharing

Source

pub fn database(&self) -> &dyn VirtualDatabase

Get a reference to the virtual database

Source

pub fn registry(&self) -> &EntityRegistry

Get the entity registry

Source

pub fn registry_mut(&mut self) -> &mut EntityRegistry

Get mutable access to the entity registry

Source

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 configuration
  • openapi_content - OpenAPI specification content (JSON or YAML)
§Returns

VBR engine with entities registered and database initialized

Source

pub async fn from_openapi_file<P: AsRef<Path>>( config: VbrConfig, file_path: P, ) -> Result<(Self, OpenApiConversionResult)>

Load VBR engine from an OpenAPI file

§Arguments
  • config - VBR configuration
  • file_path - Path to OpenAPI specification file (JSON or YAML)
§Returns

VBR engine with entities registered and database initialized

Source

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 seed
  • records - Records to insert
Source

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
Source

pub async fn seed_from_file<P: AsRef<Path>>( &self, file_path: P, ) -> Result<HashMap<String, usize>>

Load and seed from a file

§Arguments
  • file_path - Path to seed file (JSON or YAML)
Source

pub async fn clear_entity(&self, entity_name: &str) -> Result<()>

Clear all data from an entity

§Arguments
  • entity_name - Name of the entity to clear
Source

pub async fn clear_all(&self) -> Result<()>

Clear all data from all entities

Source

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 snapshot
  • description - Optional description
  • snapshots_dir - Directory to store snapshots
Source

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 snapshot
  • description - Optional description
  • snapshots_dir - Directory to store snapshots
  • include_time_travel - Whether to include time travel state
  • time_travel_state - Optional time travel state to include
Source

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 restore
  • snapshots_dir - Directory where snapshots are stored
Source

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 restore
  • snapshots_dir - Directory where snapshots are stored
  • restore_time_travel - Whether to restore time travel state
  • time_travel_restore_callback - Optional callback to restore time travel state
Source

pub async fn list_snapshots<P: AsRef<Path>>( snapshots_dir: P, ) -> Result<Vec<SnapshotMetadata>>

List all snapshots

§Arguments
  • snapshots_dir - Directory where snapshots are stored
Source

pub async fn delete_snapshot<P: AsRef<Path>>( name: &str, snapshots_dir: P, ) -> Result<()>

Delete a snapshot

§Arguments
  • name - Name of the snapshot to delete
  • snapshots_dir - Directory where snapshots are stored
Source

pub async fn reset(&self) -> Result<()>

Reset database to empty state

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: Rng + ?Sized, Self: FakeBase<U>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ParallelSend for T