Skip to main content

Acquired

Struct Acquired 

Source
pub struct Acquired<T> { /* private fields */ }
Expand description

A wrapper indicating that a resource has been acquired with a database lock.

This type is returned by database operations that lock rows for update (e.g., SELECT ... FOR UPDATE). It serves as a compile-time marker that the wrapped resource was properly locked before being returned, ensuring that subsequent modifications are safe from race conditions.

§Usage

When you need to modify a database record, first acquire it using a locking query method. The returned Acquired<T> guarantees the row is locked for the duration of the transaction.

// Acquire a quote with a row lock
let mut quote: Acquired<MintQuote> = tx.get_mint_quote_for_update(&quote_id).await?;

// Safely modify the quote (row is locked)
quote.state = QuoteState::Paid;

// Persist the changes
tx.update_mint_quote(&mut quote).await?;

§Deref Behavior

Acquired<T> implements Deref and DerefMut, allowing transparent access to the inner value’s methods and fields.

Implementations§

Source§

impl<T> Acquired<T>

Source

pub fn inner(self) -> T

Consumes the wrapper and returns the inner resource.

Use this when you need to take ownership of the inner value, for example when passing it to a function that doesn’t accept Acquired<T>.

Trait Implementations§

Source§

impl<T: Debug> Debug for Acquired<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for Acquired<T>

Source§

fn deref(&self) -> &Self::Target

Returns a reference to the inner resource.

Source§

type Target = T

The resulting type after dereferencing.
Source§

impl<T> DerefMut for Acquired<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Returns a mutable reference to the inner resource.

Source§

impl<T> From<T> for Acquired<T>

Source§

fn from(value: T) -> Self

Wraps a value to indicate it has been acquired with a lock.

This is typically called by database layer implementations after executing a locking query.

Auto Trait Implementations§

§

impl<T> Freeze for Acquired<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Acquired<T>
where T: RefUnwindSafe,

§

impl<T> Send for Acquired<T>
where T: Send,

§

impl<T> Sync for Acquired<T>
where T: Sync,

§

impl<T> Unpin for Acquired<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Acquired<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Acquired<T>
where T: UnwindSafe,

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> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<S, T> ScoreLookUp for T
where S: ScoreLookUp, T: Deref<Target = S>,

Source§

type ScoreParams = <S as ScoreLookUp>::ScoreParams

A configurable type which should contain various passed-in parameters for configuring the scorer, on a per-routefinding-call basis through to the scorer methods, which are used to determine the parameters for the suitability of channels for use.
Source§

fn channel_penalty_msat( &self, candidate: &CandidateRouteHop<'_>, usage: ChannelUsage, score_params: &<T as ScoreLookUp>::ScoreParams, ) -> u64

Returns the fee in msats willing to be paid to avoid routing send_amt_msat through the given channel in the direction from source to target. Read more
Source§

impl<S, T> ScoreUpdate for T
where S: ScoreUpdate, T: DerefMut<Target = S>,

Source§

fn payment_path_failed( &mut self, path: &Path, short_channel_id: u64, duration_since_epoch: Duration, )

Handles updating channel penalties after failing to route through a channel.
Source§

fn payment_path_successful( &mut self, path: &Path, duration_since_epoch: Duration, )

Handles updating channel penalties after successfully routing along a path.
Source§

fn probe_failed( &mut self, path: &Path, short_channel_id: u64, duration_since_epoch: Duration, )

Handles updating channel penalties after a probe over the given path failed.
Source§

fn probe_successful(&mut self, path: &Path, duration_since_epoch: Duration)

Handles updating channel penalties after a probe over the given path succeeded.
Source§

fn time_passed(&mut self, duration_since_epoch: Duration)

Scorers may wish to reduce their certainty of channel liquidity information over time. Thus, this method is provided to allow scorers to observe the passage of time - the holder of this object should call this method regularly (generally via the lightning-background-processor crate).
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> Score for T