Skip to main content

MetadataKey

Struct MetadataKey 

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

One caller-owned metadata key: <namespace>.<name>, at least two non-empty segments separated by dots, whose first segment is not MetadataKey::RESERVED_NAMESPACE.

Validated wherever one is built, deserialized included, so a plugin handed one never has to ask whether it names a key this product owns.

Implementations§

Source§

impl MetadataKey

Source

pub const RESERVED_NAMESPACE: &'static str = "onetaskgraph"

The namespace this product owns, and a narrow write therefore never names.

Every key the contract reserves lives under it — onetaskgraph.origin, onetaskgraph.repositories, onetaskgraph.depends_on, onetaskgraph.delivers, onetaskgraph.delivered_by, onetaskgraph.item_kind, onetaskgraph.template (Self::TEMPLATE_KEY), onetaskgraph.copies (Self::COPIES_KEY), onetaskgraph.members (Self::MEMBERS_KEY), onetaskgraph.member_of (Self::MEMBER_OF_KEY) and onetaskgraph.assets (Self::ASSETS_KEY) — and so does any key it reserves later, which is why the whole namespace is refused rather than a list.

Source

pub const TEMPLATE_KEY: &'static str = "onetaskgraph.template"

The reserved key a task or a document rendered from a template records where it came from under: an object holding the template’s reference, the chain digest it was rendered with, and the SHA-256 of its content and of its resolved answers.

A key of this product’s own, so no MetadataKey can name it: only a rendering write — TaskSource::write_task_rendered and TaskSource::set_task_rendering and their document siblings — ever sets it, and a copy carries it like any other entry. The engine builds and reads the value; a plugin only puts it where its metadata lives.

Source

pub const COPIES_KEY: &'static str = "onetaskgraph.copies"

The reserved key a copied item records where it landed under: a JSON object mapping a destination source name to the qualified id of that item’s counterpart there, at most one entry per destination.

A key of this product’s own, so Self::new refuses it like every other key in the namespace: only the engine’s copy writes it, through the narrow metadata write, and Self::copies is how it names the key there. A plugin only puts it where its metadata lives.

Source

pub const MEMBERS_KEY: &'static str = "onetaskgraph.members"

The reserved key a home project records its member projects under: a JSON list of qualified project ids, each in a different source from the home and from the others, so a home has at most one member per source.

Store-owned, like every key in the namespace: only the engine’s routed writes keep it — a copy, or a task create routed away from its project’s source — through the home’s own project write, and nothing a caller types can name it. A plugin only puts it where its metadata lives.

Source

pub const MEMBER_OF_KEY: &'static str = "onetaskgraph.member_of"

The reserved key a member project records its home under: the home’s qualified id.

Written once, when a routed write — a copy or a task create — creates the member, and never by a caller.

Source

pub const ASSETS_KEY: &'static str = "onetaskgraph.assets"

The reserved key a hosted source records what it uploaded for a record’s image assets under: an AssetUploads — an object keyed by asset name, each value {"sha256": <lowercase hex>, "url": <string>}.

Written by the hosted plugin itself, in the same write that lands the record, through serve_asset_references; handed back to it as AssetWrite::recorded_assets on the next copy onto that record, so an asset whose SHA-256 is unchanged reuses its URL and is not uploaded again. A copy never carries a source record’s entry to its destination: the entry says where that source serves the bytes.

Source

pub const COPIED_VERSION_KEY: &'static str = "onetaskgraph.copied_version"

The reserved key a copy records on the destination item the source Task::version it copied under — and, under --comments, a token that covered the comments it carried.

Read back by the next copy of the same item, which skips it when the source’s current version is still this one and the destination is unchanged since, by Self::COPIED_DESTINATION_VERSION_KEY. Absent when the source gave no version.

Source

pub const COPIED_WITH_COMMENTS_KEY: &'static str = "onetaskgraph.copied_with_comments"

The reserved key a --comments copy records on the destination item as the boolean true, and a copy without --comments removes: whether the copy recorded at Self::COPIED_VERSION_KEY carried the item’s comments.

A --comments copy never skips an item whose destination lacks it, so a copy that adds --comments over an unchanged source still carries the comments.

Source

pub const COPIED_DESTINATION_VERSION_KEY: &'static str = "onetaskgraph.copied_destination_version"

The reserved key a copy records on the destination item a digest of that item as the copy left it under, computed by the engine over the item without the three copied_* keys: sha256:<hex>.

A later copy skips the item only when the digest of the destination as it reads it then is still this one, so an edit of copied content at the destination — a copied comment edited or deleted included — is restored by the next copy rather than skipped.

Source

pub fn copies() -> Self

Self::COPIES_KEY, as the one reserved key a narrow metadata write may carry.

Not a way round Self::new for a caller: nothing a person types reaches this, and the one write that sends it is the copy recording where an item landed.

Source

pub fn is_copies(&self) -> bool

Whether this is Self::COPIES_KEY.

Source

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

One key, once it is established it is a caller’s own dotted key.

§Errors

Returns a message saying why, and what to write instead, when the key has no dot, has an empty segment, or is in Self::RESERVED_NAMESPACE.

Source

pub fn as_str(&self) -> &str

The key as a record’s metadata map spells it.

Trait Implementations§

Source§

impl Clone for MetadataKey

Source§

fn clone(&self) -> Self

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 MetadataKey

Source§

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

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

impl<'de> Deserialize<'de> for MetadataKey

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for MetadataKey

Source§

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

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

impl Eq for MetadataKey

Source§

impl From<MetadataKey> for String

Source§

fn from(key: MetadataKey) -> Self

Converts to this type from the input type.
Source§

impl Hash for MetadataKey

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 JsonSchema for MetadataKey

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Ord for MetadataKey

Source§

fn cmp(&self, other: &Self) -> 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§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for MetadataKey

Source§

fn eq(&self, other: &Self) -> 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 MetadataKey

Source§

fn partial_cmp(&self, other: &Self) -> 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 Serialize for MetadataKey

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MetadataKey

Source§

impl TryFrom<String> for MetadataKey

Source§

type Error = String

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

fn try_from(key: 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.