Skip to main content

Writer

Struct Writer 

Source
pub struct Writer<S: TileStore> { /* private fields */ }
Expand description

The one writer of a log. Holds .state/treeState.lock from open to drop.

Implementations§

Source§

impl<S: TileStore> Writer<S>

Source

pub fn open(store: S, keys: KeyFn) -> Result<Self>

Opens the log on store, takes the writer lock, quarantines a torn tail, loads the frontier and completes the sidecars and manifest of every sealed bundle. keys derives the lookup keys of an entry from its bytes (crate::index::no_keys for the identity hash alone); a reader has to use the same function. Error::Locked when another writer holds the lock; a lock left by a crashed writer has to be removed by hand.

Source

pub fn store(&self) -> &S

The store the writer writes.

Source

pub fn size(&self) -> u64

Entries in the log.

Source

pub fn root(&self) -> Hash

The root over every entry.

Source

pub fn tree_state(&self) -> TreeState

The tree state the tiles are complete to.

Source

pub fn quarantined(&self) -> (&[String], Option<&str>)

Store paths open moved aside because the tree state did not cover them, and the .state/torn-<utc> directory they went to.

Source

pub fn append(&mut self, entry: &[u8]) -> Result<u64>

Appends one entry and returns its index.

Source

pub fn append_batch<I>(&mut self, entries: I) -> Result<Range<u64>>
where I: IntoIterator<Item = Vec<u8>>,

Appends entries in order and returns their index range. Nothing is written when any entry is over 65535 bytes. Bundles, tiles and the tree state are each written once for the whole batch.

Source

pub fn manifest(&self) -> &Manifest

The manifest over the sealed bundles.

Source

pub fn checkpoint(&self, signer: &Signer, origin: &str) -> Result<Note>

Signs the tree state as a C2SP checkpoint under origin and writes it at checkpoint, holding .state/publish.lock meanwhile. A checkpoint already published for a larger size is never replaced, so the signer never signs a checkpoint inconsistent with one it signed. Returns the note.

Trait Implementations§

Source§

impl<S: TileStore> Drop for Writer<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Writer<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for Writer<S>

§

impl<S> Send for Writer<S>
where S: Send,

§

impl<S> Sync for Writer<S>
where S: Sync,

§

impl<S> Unpin for Writer<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Writer<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for Writer<S>

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<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> Same for T

Source§

type Output = T

Should always be Self
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.