pub struct DHTTransaction { /* private fields */ }Expand description
DHT Transactions the way you perform multiple simulateous atomic operations over a set of DHT records.
DHT operations performed out of a transaction may be processed in any order, and only operate on one subkey at a time for a given record. Transactions allow you to bind a set of operations so they all succeed, or fail together, and at the same time.
Transactional DHT operations can only be performed when the node is online, and will error with VeilidAPIError::TryAgain if offline.
Transactions must be committed when all of their operations are registered, or rolled back if the group of operations is to be cancelled.
Implementations§
Source§impl DHTTransaction
impl DHTTransaction
Sourcepub fn api(&self) -> VeilidAPI
pub fn api(&self) -> VeilidAPI
Get the VeilidAPI object that created this DHTTransaction.
Sourcepub async fn commit(self) -> VeilidAPIResult<()>
pub async fn commit(self) -> VeilidAPIResult<()>
Commit the transaction All write operations are performed atomically
Sourcepub async fn rollback(self) -> VeilidAPIResult<()>
pub async fn rollback(self) -> VeilidAPIResult<()>
Rollback the transaction No write operations are performed,
Sourcepub async fn set(
&self,
record_key: RecordKey,
subkey: ValueSubkey,
data: Vec<u8>,
options: Option<DHTTransactionSetValueOptions>,
) -> VeilidAPIResult<Option<ValueData>>
pub async fn set( &self, record_key: RecordKey, subkey: ValueSubkey, data: Vec<u8>, options: Option<DHTTransactionSetValueOptions>, ) -> VeilidAPIResult<Option<ValueData>>
Add a set_dht_value operation to the transaction
- Will fail if performed offline
- Will fail if existing offline writes exist for this record key
The writer, if specified, will override the ‘default_writer’ specified when the record is opened.
Returns None if the value was successfully set.
Returns Some(data) if the value set was older than the one available on the network.
Sourcepub async fn get(
&self,
record_key: RecordKey,
subkey: ValueSubkey,
) -> VeilidAPIResult<Option<ValueData>>
pub async fn get( &self, record_key: RecordKey, subkey: ValueSubkey, ) -> VeilidAPIResult<Option<ValueData>>
Perform a get_dht_value operation inside the transaction
- Will fail if performed offline
- Will pull the latest value from the network, will fail if the local value is newer
- Will fail if existing offline writes exist for this record key
Returns None if the value subkey has not yet been set.
Returns Some(data) if the value subkey has valid data.
Sourcepub async fn inspect(
&self,
record_key: RecordKey,
subkeys: Option<ValueSubkeyRangeSet>,
scope: DHTReportScope,
) -> VeilidAPIResult<DHTRecordReport>
pub async fn inspect( &self, record_key: RecordKey, subkeys: Option<ValueSubkeyRangeSet>, scope: DHTReportScope, ) -> VeilidAPIResult<DHTRecordReport>
Perform a inspect_dht_record operation inside the transaction
- Does not perform any network activity, as the transaction state keeps all of the required information after the begin
For information on arguments, see RoutingContext::inspect_dht_record
Returns a DHTRecordReport with the subkey ranges that were returned that overlapped the schema, and sequence numbers for each of the subkeys in the range.
Trait Implementations§
Source§impl Clone for DHTTransaction
impl Clone for DHTTransaction
Source§fn clone(&self) -> DHTTransaction
fn clone(&self) -> DHTTransaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DHTTransaction
impl !RefUnwindSafe for DHTTransaction
impl Send for DHTTransaction
impl Sync for DHTTransaction
impl Unpin for DHTTransaction
impl !UnwindSafe for DHTTransaction
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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