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>
impl<'repo> RepositoryNotes<'repo>
Sourcepub fn repository(&self) -> &'repo Repository
pub fn repository(&self) -> &'repo Repository
Borrow the underlying repository.
Sourcepub fn list(
&self,
notes_ref: &NotesRef,
limit: Option<usize>,
) -> Result<Limited<NoteListing>>
pub fn list( &self, notes_ref: &NotesRef, limit: Option<usize>, ) -> Result<Limited<NoteListing>>
Sourcepub fn list_with_bodies(
&self,
notes_ref: &NotesRef,
limit: Option<usize>,
) -> Result<Limited<Note>>
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::NotesObjectKindwhen a note entry is not a blob, and object read failures (a missing note blob is an error, not an empty note).
Sourcepub fn read(
&self,
notes_ref: &NotesRef,
object: &ObjectId,
) -> Result<Option<Vec<u8>>>
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.
Sourcepub fn plan_add(
&self,
notes_ref: &NotesRef,
object: &ObjectId,
content: &[u8],
options: &NotesWriteOptions,
force: bool,
) -> Result<NoteAddPlan>
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.
Sourcepub fn plan_remove(
&self,
notes_ref: &NotesRef,
object: &ObjectId,
options: &NotesWriteOptions,
) -> Result<NoteRemovePlan>
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.
Sourcepub fn add(
&self,
notes_ref: &NotesRef,
object: &ObjectId,
content: &[u8],
options: &NotesWriteOptions,
force: bool,
) -> Result<NoteAddOutcome>
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)?;Sourcepub fn remove(
&self,
notes_ref: &NotesRef,
object: &ObjectId,
options: &NotesWriteOptions,
) -> Result<()>
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.