Skip to main content

SourceId

Struct SourceId 

Source
pub struct SourceId(/* private fields */);
Expand description

0.8.20 Slice 5c (R-20-E3) — the provenance of a canonical row: which source document it is attributable to, and therefore what excise_source must erase when that source is withdrawn.

Why a newtype and not Option<String>. Erasure runs through provenance: a row whose source_id is NULL is reachable by NO excise_source call and is therefore un-erasable. Before 0.8.20 the public PreparedWrite carried source_id: Option<String>, so a caller could express “no provenance” and silently create such a row. A runtime rejection would not have closed this: the facade crate re-exports PreparedWrite and Engine::write is pub, so a caller can build the value directly and skip any validation the engine performs. Replacing the field’s type is what makes the absence of provenance inexpressible rather than merely rejected — the guarantee is enforced by rustc, not by a branch. tests/ui/ in the facade crate holds the compile-fail witness.

This is a BREAKING change, shipped ON by default as part of the 0.8.20 coordinated breaking-pair release. There is deliberately no compatibility shim and no deprecation window: a shim would re-open the hole it closes.

Reserved namespace. Ids beginning with _ belong to the engine and are rejected by SourceId::new. Two are currently minted internally:

  • SourceId::ENGINE_PREFIX (_engine:) — rows the engine derives for itself (EXP-S coverage/graph substrate rows), which never pass through PreparedWrite (design §4 item 6).
  • SourceId::LEGACY_PRE_0_8_20 (_legacy:pre-0.8.20) — stamped by schema migration step 21 onto pre-0.8.20 rows that were stored with NULL provenance, so they become erasable (R-20-E8). Gated to UNGOVERNED rows only (logical_id IS NULL); a governed row keeps NULL source_id and stays purge-addressable by its logical_id (TC-11 pin).

source_id must not be PII. It survives the erasure it authorises: the excise_source audit row in operational_mutations records it verbatim, and while 0.8.20 makes that audit row durable (design §2 defect D-A) the rule was always that the handle you erase BY must not itself be the thing needing erasure. Use an opaque document id, not an email address.

Implementations§

Source§

impl SourceId

Source

pub const ENGINE_PREFIX: &'static str = "_engine:"

Reserved prefix for engine-derived rows (design §4 item 6).

Source

pub const LEGACY_PRE_0_8_20: &'static str = "_legacy:pre-0.8.20"

Reserved provenance stamped by schema migration step 21 onto pre-0.8.20 UNGOVERNED rows that were stored with NULL provenance (R-20-E8).

Source

pub fn new(id: impl Into<String>) -> Result<Self, EngineError>

The single public constructor. Rejects the two ways a caller could express “effectively no provenance”:

  • an empty or whitespace-only id — it names no source, and excise_source already refuses the empty string, so such a row would be un-erasable in practice;
  • an id in the engine’s reserved _-prefixed namespace — a caller who could mint _legacy:pre-0.8.20 could hide rows among the migration’s back-filled ones, or mint _engine: rows that read as engine substrate.
§Errors

EngineError::WriteValidation for either rejection above.

Source

pub fn as_str(&self) -> &str

The on-disk source_id text.

Source

pub fn into_string(self) -> String

Consume into the owned on-disk text.

Trait Implementations§

Source§

impl AsRef<str> for SourceId

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for SourceId

Source§

fn clone(&self) -> SourceId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceId

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for SourceId

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for SourceId

Source§

impl Hash for SourceId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SourceId

Source§

fn cmp(&self, other: &SourceId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SourceId

Source§

fn eq(&self, other: &SourceId) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for SourceId

Source§

fn partial_cmp(&self, other: &SourceId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for SourceId

Source§

impl TryFrom<&str> for SourceId

Source§

type Error = EngineError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for SourceId

Source§

type Error = EngineError

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.