pub struct Spine { /* private fields */ }Expand description
Spine file handle. Clone-like sharing is by Arc inside
crate::consciousness_stream; a second process opens its own handle
over the same file and coordinates through the seqlock.
Implementations§
Source§impl Spine
impl Spine
Sourcepub fn begin_publish(&self) -> Publish<'_>
pub fn begin_publish(&self) -> Publish<'_>
Start an exclusive batch. Only use the returned guard while it lives;
calling back into this Spine would deadlock its mapping mutex.
Sourcepub fn publish_lock_is_advisory(&self) -> bool
pub fn publish_lock_is_advisory(&self) -> bool
Whether this platform supports the publisher lock and its sidecar was
opened. A runtime lock failure is reported by PublishGuard::is_advisory.
Without exclusion, independent handles must not publish concurrently.
Sourcepub fn open(output_dir: impl AsRef<Path>) -> Result<Self>
pub fn open(output_dir: impl AsRef<Path>) -> Result<Self>
Open for writing: create the file, lay out or upgrade the superblock, and mark this process as a live writer.
Sourcepub fn open_ro(output_dir: impl AsRef<Path>) -> Result<Self>
pub fn open_ro(output_dir: impl AsRef<Path>) -> Result<Self>
Open an existing spine for reading: no create, no sizing, no writer
mark, and no resize. Readers need no lock to be safe, because
Spine::read_snapshot validates against the seqlock instead.
Sourcepub fn write_slot(&self, slot: Slot, bytes: &[u8; 16384])
pub fn write_slot(&self, slot: Slot, bytes: &[u8; 16384])
Publish one page in its own window. For related updates, use
begin_publish instead. Superblock writes exclude the counter bytes.
pub fn read_stream(&self) -> StreamHeader
pub fn write_stream(&self, h: &StreamHeader)
Sourcepub fn tick(
&self,
cycle: u64,
surprise: f32,
curiosity: f32,
predicted_hash: u64,
predicted_confidence: f32,
last_query_hash: u64,
last_query_ms: u64,
hebbian_total_energy: f64,
)
pub fn tick( &self, cycle: u64, surprise: f32, curiosity: f32, predicted_hash: u64, predicted_confidence: f32, last_query_hash: u64, last_query_ms: u64, hebbian_total_energy: f64, )
Publish the stream and superblock in one exclusive window.
Use begin_publish to include layer headers in the same window.
Sourcepub fn read_snapshot(&self) -> Option<PublishSnapshot>
pub fn read_snapshot(&self) -> Option<PublishSnapshot>
The stream and superblock copied under one even counter value.
Returns None after the retry/time budget or for an invalid payload.
Sourcepub fn read_store_snapshot(&self) -> Option<StoreSnapshot>
pub fn read_store_snapshot(&self) -> Option<StoreSnapshot>
All eleven headers and the superblock from one validated copy. This does not imply equal freshness of infrequently updated layers.
Sourcepub fn publish_window_open(&self) -> bool
pub fn publish_window_open(&self) -> bool
Whether the store’s publish window is open: while a writer is inside
one, and — the reason this is worth exposing — while a writer that was
killed leaves one open. Spine::recover_stalled_publish clears the
second case.
Sourcepub fn recover_stalled_publish(&self) -> bool
pub fn recover_stalled_publish(&self) -> bool
Close a publish window whose writer is gone.
A SIGKILL between the odd store and the even one leaves the counter
odd, and every reader would then spend its whole budget on a window that
never closes, forever. This is the repair: take the publisher lock
(blocking, which is also what proves no live writer is inside a window)
and, if the counter is still the odd value found without the lock,
close it.
Returns true only when a window was actually closed. There is no
timeout involved, so a writer that is merely slow is never interrupted:
tick() opens and closes its window with the publisher lock held, and
the lock is what makes that argument work.
Sourcepub fn publish_sequence(&self) -> u64
pub fn publish_sequence(&self) -> u64
Publish counter right now. 0 on a file too short to carry one.
Sourcepub fn publish_in_flight(&self) -> bool
pub fn publish_in_flight(&self) -> bool
True while some writer is mid-publish. Readers never have to act on
it — read_snapshot retries on its own — but the live viewer uses it
to explain a stalled tick_seq without claiming a torn read.
pub fn read_hebbian(&self) -> HebbianHeader
pub fn write_hebbian(&self, h: &HebbianHeader)
pub fn read_attention(&self) -> AttentionHeader
pub fn write_attention(&self, h: &AttentionHeader)
pub fn read_emotion(&self) -> EmotionHeader
pub fn write_emotion(&self, h: &EmotionHeader)
pub fn read_resonance(&self) -> ResonanceHeader
pub fn write_resonance(&self, h: &ResonanceHeader)
pub fn read_graph(&self) -> GraphHeader
pub fn write_graph(&self, h: &GraphHeader)
pub fn read_cache(&self) -> CacheHeader
pub fn write_cache(&self, h: &CacheHeader)
pub fn read_archetype(&self) -> ArchetypeHeader
pub fn write_archetype(&self, h: &ArchetypeHeader)
pub fn read_mirror(&self) -> MirrorHeader
pub fn write_mirror(&self, h: &MirrorHeader)
pub fn read_merkle(&self) -> MerkleHeader
pub fn write_merkle(&self, h: &MerkleHeader)
pub fn read_meta(&self) -> MetaHeader
pub fn write_meta(&self, h: &MetaHeader)
Sourcepub fn read_superblock(&self) -> Option<Superblock>
pub fn read_superblock(&self) -> Option<Superblock>
The superblock as stored. Prefer Spine::read_snapshot when the
value has to agree with a stream header.
pub fn sync(&self) -> Result<()>
pub fn size_bytes(&self) -> usize
pub fn output_dir(&self) -> &Path
pub fn path(&self) -> PathBuf
Auto Trait Implementations§
impl !RefUnwindSafe for Spine
impl !UnwindSafe for Spine
impl Freeze for Spine
impl Send for Spine
impl Sync for Spine
impl Unpin for Spine
impl UnsafeUnpin for Spine
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more