Skip to main content

RepositoryNotes

Struct RepositoryNotes 

Source
pub struct RepositoryNotes<'repo> { /* private fields */ }
Expand description

Notes read/write for one open repository (default ref: NotesRef::commits).

Implementations§

Source§

impl<'repo> RepositoryNotes<'repo>

Source

pub fn repository(&self) -> &'repo Repository

Borrow the underlying repository.

Source

pub fn list( &self, notes_ref: &NotesRef, limit: Option<usize>, ) -> Result<Limited<NoteListing>>

List notes under notes_ref.

§Errors

Propagates notes tree read failures.

§Examples
let repo = Repository::discover(Some(Path::new(".")), &grit_lib::config::environment::RepositoryOptions::empty())?;
let notes = repo.notes().list(&NotesRef::commits(), None)?;
let _ = notes.items.len();
Source

pub fn list_with_bodies( &self, notes_ref: &NotesRef, limit: Option<usize>, ) -> Result<Limited<Note>>

List notes under notes_ref together with their contents, sorted by annotated object.

§Errors
  • Notes tree read failures (see Self::list).
  • Error::NotesObjectKind when a note entry is not a blob, and object read failures (a missing note blob is an error, not an empty note).
Source

pub fn read( &self, notes_ref: &NotesRef, object: &ObjectId, ) -> Result<Option<Vec<u8>>>

Read note bytes for object, if present.

§Errors

Propagates notes tree and object read failures; Error::NotesObjectKind when the note entry is not a blob.

Source

pub fn plan_add( &self, notes_ref: &NotesRef, object: &ObjectId, content: &[u8], options: &NotesWriteOptions, force: bool, ) -> Result<NoteAddPlan>

Preview Self::add without persisting blobs, trees, commits, or refs.

Object writes are confined to the ODB in-memory overlay and discarded before return.

§Errors

Same as Self::add, including Error::NoteAlreadyExists when force is false and a note already exists.

Source

pub fn plan_remove( &self, notes_ref: &NotesRef, object: &ObjectId, options: &NotesWriteOptions, ) -> Result<NoteRemovePlan>

Preview Self::remove on object without persisting blobs, trees, commits, or refs.

§Errors

Propagates notes tree read failures.

Source

pub fn add( &self, notes_ref: &NotesRef, object: &ObjectId, content: &[u8], options: &NotesWriteOptions, force: bool, ) -> Result<NoteAddOutcome>

Add or replace the note on object; content is stored exactly as given.

When force is false and a note already exists, returns Error::NoteAlreadyExists.

§Returns

Whether the note was newly Added or Replaced.

§Errors

Propagates notes tree read errors (invalid existing notes ref), blob write, and notes commit failures. The notes ref is updated only if it still points at the tip the existing notes were read from, so a concurrent notes update fails this call instead of being dropped.

§Examples
let opts = NotesWriteOptions {
    message: "add note".into(),
    committer: "User <u@example.com> 1000000000 +0000".parse()?,
    author: None,
};
repo.notes().add(&NotesRef::commits(), &object, b"text\n", &opts, false)?;
Source

pub fn remove( &self, notes_ref: &NotesRef, object: &ObjectId, options: &NotesWriteOptions, ) -> Result<()>

Remove the note on object when present.

§Errors

Propagates notes commit failures when a note existed.

Source

pub fn remove_many( &self, notes_ref: &NotesRef, objects: &[ObjectId], options: &NotesWriteOptions, ) -> Result<Vec<ObjectId>>

Remove notes on each object in objects, writing at most one notes commit.

Returns the object ids whose notes were removed.

§Errors

Propagates notes tree read and commit failures, including the compare-and-swap failure described on Self::add when the notes ref moves concurrently.

Trait Implementations§

Source§

impl<'repo> Clone for RepositoryNotes<'repo>

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<'repo> Copy for RepositoryNotes<'repo>

Source§

impl<'repo> Debug for RepositoryNotes<'repo>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'repo> !RefUnwindSafe for RepositoryNotes<'repo>

§

impl<'repo> !UnwindSafe for RepositoryNotes<'repo>

§

impl<'repo> Freeze for RepositoryNotes<'repo>

§

impl<'repo> Send for RepositoryNotes<'repo>

§

impl<'repo> Sync for RepositoryNotes<'repo>

§

impl<'repo> Unpin for RepositoryNotes<'repo>

§

impl<'repo> UnsafeUnpin for RepositoryNotes<'repo>

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