Struct Transaction

Source
pub struct Transaction<T, R>
where T: Cob + Evaluate<R>,
{ /* private fields */ }
Expand description

Allows operations to be batched atomically.

Implementations§

Source§

impl<R> Transaction<Identity, R>
where R: ReadRepository,

Source

pub fn accept( &mut self, revision: Oid, signature: Signature, ) -> Result<(), Error>

Source

pub fn reject(&mut self, revision: Oid) -> Result<(), Error>

Source

pub fn edit( &mut self, revision: Oid, title: impl ToString, description: impl ToString, ) -> Result<(), Error>

Source

pub fn redact(&mut self, revision: Oid) -> Result<(), Error>

Source§

impl<R> Transaction<Identity, R>
where R: WriteRepository,

Source

pub fn revision<G>( &mut self, title: impl ToString, description: impl ToString, doc: &Doc, parent: Option<Oid>, repo: &R, signer: &Device<G>, ) -> Result<(), Error>
where G: Signer<Signature>,

Source§

impl<R> Transaction<Issue, R>
where R: ReadRepository,

Source

pub fn assign( &mut self, assignees: impl IntoIterator<Item = Did>, ) -> Result<(), Error>

Assign DIDs to the issue.

Source

pub fn edit_comment( &mut self, id: Oid, body: impl ToString, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>

Edit an issue comment.

Source

pub fn edit(&mut self, title: impl ToString) -> Result<(), Error>

Set the issue title.

Source

pub fn redact_comment(&mut self, id: Oid) -> Result<(), Error>

Redact a comment.

Source

pub fn lifecycle(&mut self, state: State) -> Result<(), Error>

Lifecycle an issue.

Source

pub fn comment<S>( &mut self, body: S, reply_to: Oid, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>
where S: ToString,

Comment on an issue.

Source

pub fn label( &mut self, labels: impl IntoIterator<Item = Label>, ) -> Result<(), Error>

Label an issue.

Source

pub fn react( &mut self, id: Oid, reaction: Reaction, active: bool, ) -> Result<(), Error>

React to an issue comment.

Source§

impl<R> Transaction<Patch, R>
where R: ReadRepository,

Source

pub fn edit( &mut self, title: impl ToString, target: MergeTarget, ) -> Result<(), Error>

Source

pub fn edit_revision( &mut self, revision: RevisionId, description: impl ToString, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>

Source

pub fn redact(&mut self, revision: RevisionId) -> Result<(), Error>

Redact the revision.

Source

pub fn thread<S>(&mut self, revision: RevisionId, body: S) -> Result<(), Error>
where S: ToString,

Start a patch revision discussion.

Source

pub fn react( &mut self, revision: RevisionId, reaction: Reaction, location: Option<CodeLocation>, active: bool, ) -> Result<(), Error>

React on a patch revision.

Source

pub fn comment<S>( &mut self, revision: RevisionId, body: S, reply_to: Option<Oid>, location: Option<CodeLocation>, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>
where S: ToString,

Comment on a patch revision.

Source

pub fn comment_edit<S>( &mut self, revision: RevisionId, comment: Oid, body: S, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>
where S: ToString,

Edit a comment on a patch revision.

Source

pub fn comment_react( &mut self, revision: RevisionId, comment: Oid, reaction: Reaction, active: bool, ) -> Result<(), Error>

React a comment on a patch revision.

Source

pub fn comment_redact( &mut self, revision: RevisionId, comment: Oid, ) -> Result<(), Error>

Redact a comment on a patch revision.

Source

pub fn review_comment<S>( &mut self, review: ReviewId, body: S, location: Option<CodeLocation>, reply_to: Option<Oid>, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>
where S: ToString,

Comment on a review.

Source

pub fn review_comment_resolve( &mut self, review: ReviewId, comment: Oid, ) -> Result<(), Error>

Resolve a review comment.

Source

pub fn review_comment_unresolve( &mut self, review: ReviewId, comment: Oid, ) -> Result<(), Error>

Unresolve a review comment.

Source

pub fn edit_review_comment<S>( &mut self, review: ReviewId, comment: Oid, body: S, embeds: Vec<Embed<Uri>>, ) -> Result<(), Error>
where S: ToString,

Edit review comment.

Source

pub fn react_review_comment( &mut self, review: ReviewId, comment: Oid, reaction: Reaction, active: bool, ) -> Result<(), Error>

React to a review comment.

Source

pub fn redact_review_comment( &mut self, review: ReviewId, comment: Oid, ) -> Result<(), Error>

Redact a review comment.

Source

pub fn review( &mut self, revision: RevisionId, verdict: Option<Verdict>, summary: Option<String>, labels: Vec<Label>, ) -> Result<(), Error>

Review a patch revision. Does nothing if a review for that revision already exists by the author.

Source

pub fn review_edit( &mut self, review: ReviewId, verdict: Option<Verdict>, summary: String, labels: Vec<Label>, embeds: impl IntoIterator<Item = Embed<Uri>>, ) -> Result<(), Error>

Edit a review.

Source

pub fn review_react( &mut self, review: ReviewId, reaction: Reaction, active: bool, ) -> Result<(), Error>

React to a review.

Source

pub fn redact_review(&mut self, review: ReviewId) -> Result<(), Error>

Redact a patch review.

Source

pub fn merge(&mut self, revision: RevisionId, commit: Oid) -> Result<(), Error>

Merge a patch revision.

Source

pub fn revision( &mut self, description: impl ToString, base: impl Into<Oid>, oid: impl Into<Oid>, ) -> Result<(), Error>

Update a patch with a new revision.

Source

pub fn lifecycle(&mut self, state: Lifecycle) -> Result<(), Error>

Lifecycle a patch.

Source

pub fn assign(&mut self, assignees: BTreeSet<Did>) -> Result<(), Error>

Assign a patch.

Source

pub fn label( &mut self, labels: impl IntoIterator<Item = Label>, ) -> Result<(), Error>

Label a patch.

Source§

impl<T, R> Transaction<T, R>
where T: Cob + Evaluate<R>,

Source

pub fn new( type_name: TypeName, actions: Vec<<T as Cob>::Action>, embeds: Vec<Embed<Uri>>, ) -> Transaction<T, R>

Source§

impl<T, R> Transaction<T, R>
where T: Cob + CobWithType + Evaluate<R>,

Source

pub fn initial<G, F, Tx>( message: &str, store: &mut Store<'_, T, R>, signer: &Device<G>, operations: F, ) -> Result<(ObjectId, T), Error>
where Tx: From<Transaction<T, R>>, Transaction<T, R>: From<Tx>, G: Signer<Signature>, F: FnOnce(&mut Tx, &R) -> Result<(), Error>, R: ReadRepository + SignRepository + Store<Namespace = PublicKey>, <T as Cob>::Action: Serialize + Clone,

Create a new transaction to be used as the initial set of operations for a COB.

Source§

impl<T, R> Transaction<T, R>
where T: Cob + Evaluate<R>,

Source

pub fn push(&mut self, action: <T as Cob>::Action) -> Result<(), Error>

Add an action to this transaction.

Source

pub fn extend<I>(&mut self, actions: I) -> Result<(), Error>
where I: IntoIterator<Item = <T as Cob>::Action>,

Add actions to this transaction. Note that we cannot implement std::iter::Extend because Self::push validates the action being pushed, and therefore is falliable.

Source

pub fn embed( &mut self, embeds: impl IntoIterator<Item = Embed<Uri>>, ) -> Result<(), Error>

Embed media into the transaction.

Source

pub fn commit<G>( self, msg: &str, id: ObjectId, store: &mut Store<'_, T, R>, signer: &Device<G>, ) -> Result<(T, Oid), Error>

Commit transaction.

Returns an operation that can be applied onto an in-memory state.

Trait Implementations§

Source§

impl<T, R> Debug for Transaction<T, R>
where T: Debug + Cob + Evaluate<R>, R: Debug, <T as Cob>::Action: Debug,

Source§

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

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

impl<T, R> Default for Transaction<T, R>
where T: Cob + CobWithType + Evaluate<R>,

Source§

fn default() -> Transaction<T, R>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, R> Freeze for Transaction<T, R>

§

impl<T, R> RefUnwindSafe for Transaction<T, R>

§

impl<T, R> Send for Transaction<T, R>
where R: Send, <T as Cob>::Action: Send,

§

impl<T, R> Sync for Transaction<T, R>
where R: Sync, <T as Cob>::Action: Sync,

§

impl<T, R> Unpin for Transaction<T, R>
where R: Unpin, <T as Cob>::Action: Unpin,

§

impl<T, R> UnwindSafe for Transaction<T, R>
where R: UnwindSafe, <T as Cob>::Action: UnwindSafe,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoInit<ZeroInit> for T

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,