pub struct HandoffReader<T> { /* private fields */ }Expand description
Reads locator handoff records from block storage.
Each poll call reads the block lease, deserializes
the handoff state, and returns Some(state) if the generation has changed
since the last successful poll.
§Fail-closed
If the block data is corrupt or deserialization fails, poll returns an
error — never a stale or default value.
§Example
use grafos_locator::handoff::HandoffReader;
use grafos_locator::locator::QueueLocator;
use grafos_std::block::BlockBuilder;
let lease = BlockBuilder::new().acquire().unwrap();
let mut reader: HandoffReader<QueueLocator> = HandoffReader::new(lease);
match reader.poll() {
Ok(Some(state)) => println!("new locator: {:?}", state.locator),
Ok(None) => println!("no change"),
Err(e) => println!("read error: {e}"),
}Implementations§
Source§impl<T: Serialize + DeserializeOwned + Clone> HandoffReader<T>
impl<T: Serialize + DeserializeOwned + Clone> HandoffReader<T>
Sourcepub fn new(block_lease: BlockLease) -> Self
pub fn new(block_lease: BlockLease) -> Self
Create a new handoff reader attached to the given block lease.
Sourcepub fn poll(&mut self) -> Result<Option<HandoffState<T>>>
pub fn poll(&mut self) -> Result<Option<HandoffState<T>>>
Poll the block storage for a new handoff state.
Returns Ok(Some(state)) if the generation has changed since the
last successful poll, Ok(None) if unchanged, or Err on I/O or
deserialization failure.
Sourcepub fn last_generation(&self) -> Option<FenceEpoch>
pub fn last_generation(&self) -> Option<FenceEpoch>
Returns the last generation seen by poll, if any.
Sourcepub fn last_locator(&self) -> Option<&T>
pub fn last_locator(&self) -> Option<&T>
Returns a reference to the last locator seen by poll, if any.
Auto Trait Implementations§
impl<T> Freeze for HandoffReader<T>where
T: Freeze,
impl<T> !RefUnwindSafe for HandoffReader<T>
impl<T> !Send for HandoffReader<T>
impl<T> !Sync for HandoffReader<T>
impl<T> Unpin for HandoffReader<T>where
T: Unpin,
impl<T> !UnwindSafe for HandoffReader<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
Mutably borrows from an owned value. Read more