pub struct TransactionalState { /* private fields */ }Expand description
Transactional wrapper for REPL state with O(1) checkpoint/rollback
Implementations§
Source§impl TransactionalState
impl TransactionalState
Sourcepub fn new(max_memory: usize) -> Self
pub fn new(max_memory: usize) -> Self
Create a new transactional state with the given memory limit
§Examples
use ruchy::runtime::transaction::TransactionalState;
let instance = TransactionalState::new();
// Verify behavior§Examples
use ruchy::runtime::transaction::TransactionalState;
let instance = TransactionalState::new();
// Verify behavior§Examples
use ruchy::runtime::transaction::TransactionalState;
let instance = TransactionalState::new();
// Verify behaviorSourcepub fn begin_transaction(
&mut self,
metadata: TransactionMetadata,
) -> Result<TransactionId>
pub fn begin_transaction( &mut self, metadata: TransactionMetadata, ) -> Result<TransactionId>
Begin a new transaction
§Examples
use ruchy::runtime::transaction::TransactionalState;
let mut instance = TransactionalState::new();
let result = instance.begin_transaction();
// Verify behaviorSourcepub fn commit_transaction(&mut self, id: TransactionId) -> Result<()>
pub fn commit_transaction(&mut self, id: TransactionId) -> Result<()>
Sourcepub fn rollback_transaction(&mut self, id: TransactionId) -> Result<()>
pub fn rollback_transaction(&mut self, id: TransactionId) -> Result<()>
Sourcepub fn check_transaction_limits(&self, id: TransactionId) -> Result<()>
pub fn check_transaction_limits(&self, id: TransactionId) -> Result<()>
Sourcepub fn bindings_mut(&mut self) -> &mut HashMap<String, Value>
pub fn bindings_mut(&mut self) -> &mut HashMap<String, Value>
Sourcepub fn insert_binding(&mut self, name: String, value: Value, mutable: bool)
pub fn insert_binding(&mut self, name: String, value: Value, mutable: bool)
Sourcepub fn is_mutable(&self, name: &str) -> bool
pub fn is_mutable(&self, name: &str) -> bool
Sourcepub fn arena(&self) -> &Arena
pub fn arena(&self) -> &Arena
Get arena for allocation
§Examples
use ruchy::runtime::transaction::TransactionalState;
let state = TransactionalState::new();
let arena = state.arena();
assert!(arena.used() >= 0);Sourcepub fn memory_used(&self) -> usize
pub fn memory_used(&self) -> usize
Auto Trait Implementations§
impl Freeze for TransactionalState
impl !RefUnwindSafe for TransactionalState
impl !Send for TransactionalState
impl !Sync for TransactionalState
impl Unpin for TransactionalState
impl !UnwindSafe for TransactionalState
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
Mutably borrows from an owned value. Read more
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>
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 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>
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