Selector

Struct Selector 

Source
pub struct Selector<'c> { /* private fields */ }
Expand description

A coin selector

Implementations§

Source§

impl<'c> Selector<'c>

Source

pub fn new( candidates: &'c InputCandidates, params: SelectorParams, ) -> Result<Self, SelectorError>

Create new input selector.

§Errors
  • If we are unable to create a change policy from the params.
  • If the target is unreachable given the total input value.
Source

pub fn inner(&self) -> &CoinSelector<'c>

Get the inner coin selector.

Source

pub fn inner_mut(&mut self) -> &mut CoinSelector<'c>

Get a mutable reference to the inner coin selector.

Source

pub fn target(&self) -> Target

Coin selection target.

Source

pub fn change_policy(&self) -> ChangePolicy

Coin selection change policy.

Source

pub fn select_with_algorithm<F, E>(&mut self, algorithm: F) -> Result<(), E>
where F: FnMut(&mut Selector<'_>) -> Result<(), E>,

Select with the provided algorithm.

Source

pub fn select_all(&mut self)

Select all.

Source

pub fn select_until_target_met(&mut self) -> Result<(), InsufficientFunds>

Select in order until target is met.

Source

pub fn has_change(&self) -> Option<bool>

Whether we added the change output to the selection.

Return None if target is not met yet.

Source

pub fn try_finalize(&self) -> Option<Selection>

Try get final selection.

Return None if target is not met yet.

Trait Implementations§

Source§

impl<'c> Clone for Selector<'c>

Source§

fn clone(&self) -> Selector<'c>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'c> Debug for Selector<'c>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c> !Freeze for Selector<'c>

§

impl<'c> RefUnwindSafe for Selector<'c>

§

impl<'c> Send for Selector<'c>

§

impl<'c> Sync for Selector<'c>

§

impl<'c> Unpin for Selector<'c>

§

impl<'c> UnwindSafe for Selector<'c>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.