Skip to main content

CommentOrigin

Struct CommentOrigin 

Source
pub struct CommentOrigin {
    pub task: String,
    pub id: NativeId,
    pub author: Option<String>,
    pub created_at: Option<DateTime<Utc>>,
    pub updated_at: Option<DateTime<Utc>>,
    pub url: Option<String>,
}
Expand description

Where a copied comment came from: the comment as its origin holds it.

Fields§

§task: String

The task the comment is on at its origin, qualified: <source>:<native task id>.

§id: NativeId

The comment’s own id at its origin.

§author: Option<String>

Who wrote it there, in that source’s spelling of a person.

§created_at: Option<DateTime<Utc>>

When the origin says it was written.

§updated_at: Option<DateTime<Utc>>

When the origin says it last changed.

§url: Option<String>

Where a person can open it at its origin.

Implementations§

Source§

impl CommentOrigin

Source

pub fn is_qualified_task(task: &str) -> bool

Whether task is a qualified task id — <source>:<native task id>, the source a valid source name and the native id not empty — and so can be an origin’s task.

What a reader holds to before it takes a stored origin as one: the origin’s task decides which copies a sync owns, edits and deletes, and which comments it never sends back, so one naming no task is no origin at all and is read as the text it was stored as.

Source

pub fn qualified(&self) -> Result<&Self, SourceError>

This origin, refused as SourceError::Malformed when its task is not a qualified task id — what every writer of a copied comment holds an origin to before it writes one, since such an origin would be stored and then read back as none.

§Errors

SourceError::Malformed, naming the task it was given.

Source

pub fn mark(&self, body: &str) -> String

body with this origin appended as a hidden marker, for a source that cannot store a comment’s origin, author or times natively.

One line, an HTML comment whose payload is compact JSON inside a code span — <!-- onetaskgraph.comment_origin `{…}` --> — because that is the spelling both hosted services this product drives keep byte for byte (the Linear plugin’s module documentation records what Linear does to every other one). <, > and ` are escaped inside the JSON, where the escape means the same character, so no value can close the marker early.

Source§

impl CommentOrigin

Source

pub fn kept(held: &str, body: &CommentBody) -> Result<CommentBody, SourceError>

body, carrying over the hidden marker the comment it replaces ends in — held, that comment’s body exactly as its source holds it — when body ends in none of its own.

What a source that keeps a copied comment’s origin as the marker answers an edit with: an edit changes what a comment says and nothing else, so a comment a copy wrote is still that copy afterwards, and the next copy keeps it in step rather than writing another beside it. A body that ends in a marker of its own — a copy rewriting its own comment — is left as it is.

§Errors

None in practice, because the body only grows: SourceError::Refused is what CommentBody::new answers an empty text with.

Trait Implementations§

Source§

impl Clone for CommentOrigin

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 CommentOrigin

Source§

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

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

impl<'de> Deserialize<'de> for CommentOrigin

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 Eq for CommentOrigin

Source§

impl JsonSchema for CommentOrigin

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 PartialEq for CommentOrigin

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 Serialize for CommentOrigin

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 CommentOrigin

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, 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.