pub struct BlockHolder<T: BlockMetadata> { /* private fields */ }Expand description
RAII container for holding blocks during sessions. RAII block holder - tier-agnostic, just holds blocks.
§Type Parameter
T is the tier metadata type (e.g., G2, G3). It must implement
BlockMetadata which is Clone + Send + Sync + 'static.
§RAII Semantics
When BlockHolder is dropped, all held blocks are released. This ensures
blocks don’t leak even if session handling panics.
§Example
// Create holder with searched blocks
let mut holder = BlockHolder::new(g2_blocks);
// Check what we have
println!("Holding {} blocks", holder.count());
// Release some blocks (e.g., after RDMA pull)
holder.release(&pulled_hashes);
// Holder drops here, releasing any remaining blocksImplementations§
Source§impl<T: BlockMetadata> BlockHolder<T>
impl<T: BlockMetadata> BlockHolder<T>
Sourcepub fn new(blocks: Vec<ImmutableBlock<T>>) -> Self
pub fn new(blocks: Vec<ImmutableBlock<T>>) -> Self
Create a new BlockHolder with the given blocks.
Sourcepub fn blocks(&self) -> &[ImmutableBlock<T>]
pub fn blocks(&self) -> &[ImmutableBlock<T>]
Get a reference to the held blocks.
Sourcepub fn extend(&mut self, blocks: impl IntoIterator<Item = ImmutableBlock<T>>)
pub fn extend(&mut self, blocks: impl IntoIterator<Item = ImmutableBlock<T>>)
Add blocks to this holder.
Sourcepub fn release(&mut self, hashes: &[SequenceHash])
pub fn release(&mut self, hashes: &[SequenceHash])
Release blocks matching the given sequence hashes.
Removes blocks from the holder whose sequence hash is in hashes.
The blocks are dropped, releasing their references.
Sourcepub fn retain(&mut self, hashes: &[SequenceHash])
pub fn retain(&mut self, hashes: &[SequenceHash])
Retain only blocks matching the given sequence hashes.
Removes blocks from the holder whose sequence hash is NOT in hashes.
The removed blocks are dropped, releasing their references.
Sourcepub fn take_all(&mut self) -> Vec<ImmutableBlock<T>>
pub fn take_all(&mut self) -> Vec<ImmutableBlock<T>>
Take all blocks out of this holder.
The holder becomes empty. Useful for transferring blocks to another location or for processing before dropping.
Sourcepub fn sequence_hashes(&self) -> Vec<SequenceHash> ⓘ
pub fn sequence_hashes(&self) -> Vec<SequenceHash> ⓘ
Get sequence hashes of all held blocks.
Sourcepub fn find(&self, hash: &SequenceHash) -> Option<&ImmutableBlock<T>>
pub fn find(&self, hash: &SequenceHash) -> Option<&ImmutableBlock<T>>
Find a block by sequence hash.
Sourcepub fn contains(&self, hash: &SequenceHash) -> bool
pub fn contains(&self, hash: &SequenceHash) -> bool
Check if a block with the given hash is held.
Sourcepub fn iter(&self) -> impl Iterator<Item = &ImmutableBlock<T>>
pub fn iter(&self) -> impl Iterator<Item = &ImmutableBlock<T>>
Iterate over held blocks.
Trait Implementations§
Source§impl<T: Debug + BlockMetadata> Debug for BlockHolder<T>
impl<T: Debug + BlockMetadata> Debug for BlockHolder<T>
Source§impl<T: BlockMetadata> Default for BlockHolder<T>
impl<T: BlockMetadata> Default for BlockHolder<T>
Source§impl<T: BlockMetadata> FromIterator<ImmutableBlock<T>> for BlockHolder<T>
impl<T: BlockMetadata> FromIterator<ImmutableBlock<T>> for BlockHolder<T>
Source§fn from_iter<I: IntoIterator<Item = ImmutableBlock<T>>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = ImmutableBlock<T>>>(iter: I) -> Self
Source§impl<T: BlockMetadata> IntoIterator for BlockHolder<T>
impl<T: BlockMetadata> IntoIterator for BlockHolder<T>
Source§impl<'a, T: BlockMetadata> IntoIterator for &'a BlockHolder<T>
impl<'a, T: BlockMetadata> IntoIterator for &'a BlockHolder<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for BlockHolder<T>
impl<T> !UnwindSafe for BlockHolder<T>
impl<T> Freeze for BlockHolder<T>
impl<T> Send for BlockHolder<T>
impl<T> Sync for BlockHolder<T>
impl<T> Unpin for BlockHolder<T>
impl<T> UnsafeUnpin for BlockHolder<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);