pub struct Note {
pub id: ObjectHash,
pub target_object_id: ObjectHash,
pub content: String,
}Expand description
Git Note object structure
A Note represents additional metadata attached to a Git object (typically a commit). The Note itself is stored as a Blob object in Git’s object database, with the association managed through Git’s reference system.
Fields§
§id: ObjectHashThe ObjectHash of this Note object (same as the underlying Blob)
target_object_id: ObjectHashThe ObjectHash of the object this Note annotates (usually a commit)
content: StringThe textual content of the Note
Implementations§
Source§impl Note
impl Note
Sourcepub fn new_with_kind(
kind: HashKind,
target_object_id: ObjectHash,
content: String,
) -> Result<Self, GitError>
pub fn new_with_kind( kind: HashKind, target_object_id: ObjectHash, content: String, ) -> Result<Self, GitError>
Create a new Note for the specified target object with the given content
§Arguments
target_object_id- The ObjectHash of the object to annotatecontent- The textual content of the note
Create a Note for target_object_id with an explicit repository kind.
Notes are hashed as blobs. Does not consult the thread-local
HashKind; the target ID must belong to kind, otherwise the call
fails closed with GitError::InvalidHashValue. Never panics.
Sourcepub fn from_content_with_kind(
kind: HashKind,
content: &str,
) -> Result<Self, GitError>
pub fn from_content_with_kind( kind: HashKind, content: &str, ) -> Result<Self, GitError>
Create a Note with a placeholder (zero) target of an explicit repository kind.
The placeholder target is ObjectHash::zero_for_kind so that it has the
right width for the repository; see Note::from_content for the
thread-local variant.
Sourcepub fn new(target_object_id: ObjectHash, content: String) -> Self
pub fn new(target_object_id: ObjectHash, content: String) -> Self
§Returns
A new Note instance with calculated ID based on the content
Uses the thread-local HashKind; see Note::new_with_kind.
Sourcepub fn from_content(content: &str) -> Self
pub fn from_content(content: &str) -> Self
Create a Note from content string, with default target object
This is a convenience method for creating Notes when the target will be set later by the notes management system.
§Arguments
content- The textual content of the note
§Returns
A new Note instance with default target object ID
The default target is the SHA-1 zero ID regardless of the thread-local
kind (legacy behaviour); see Note::from_content_with_kind for a
kind-correct placeholder.
Sourcepub fn content_size(&self) -> usize
pub fn content_size(&self) -> usize
Get the size of the Note content in bytes
Sourcepub fn set_target(&mut self, new_target: ObjectHash)
pub fn set_target(&mut self, new_target: ObjectHash)
Update the target object ID for this Note
This method allows changing which object this Note annotates without changing the Note’s content or ID.
§Arguments
new_target- The new target object SHA-1/ SHA-256 hash
Sourcepub fn from_bytes_with_target(
data: &[u8],
hash: ObjectHash,
target_object_id: ObjectHash,
) -> Result<Self, GitError>
pub fn from_bytes_with_target( data: &[u8], hash: ObjectHash, target_object_id: ObjectHash, ) -> Result<Self, GitError>
Create a Note object from raw bytes with explicit target object ID
This is the preferred method when you know both the content and the target object, as it preserves the complete Note association information.
§Arguments
data- The raw byte data (UTF-8 encoded text content)hash- The SHA-1/ SHA-256 hash of this Note objecttarget_object_id- The SHA-1/ SHA-256 hash of the object this Note annotates
§Returns
A Result containing the Note object with complete association info
Sourcepub fn to_data_with_target(&self) -> Result<(Vec<u8>, ObjectHash), GitError>
pub fn to_data_with_target(&self) -> Result<(Vec<u8>, ObjectHash), GitError>
Serialize a Note with its target association for external storage
This method returns both the Git object data and the target object ID, which can be used by higher-level systems to manage the refs/notes/* references.
§Returns
A tuple of (object_data, target_object_id)
Trait Implementations§
Source§impl Archive for Note
impl Archive for Note
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedNote
type Archived = ArchivedNote
Source§type Resolver = NoteResolver
type Resolver = NoteResolver
Source§impl<'de> Deserialize<'de> for Note
impl<'de> Deserialize<'de> for Note
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__D: Fallible + ?Sized> Deserialize<Note, __D> for Archived<Note>where
ObjectHash: Archive,
<ObjectHash as Archive>::Archived: Deserialize<ObjectHash, __D>,
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Note, __D> for Archived<Note>where
ObjectHash: Archive,
<ObjectHash as Archive>::Archived: Deserialize<ObjectHash, __D>,
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
impl Eq for Note
Source§impl ObjectTrait for Note
impl ObjectTrait for Note
Source§fn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>where
Self: Sized,
fn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>where
Self: Sized,
Source§fn get_type(&self) -> ObjectType
fn get_type(&self) -> ObjectType
Get the Git object type for Notes
Notes are stored as Blob objects in Git’s object database
Source§fn to_data(&self) -> Result<Vec<u8>, GitError>
fn to_data(&self) -> Result<Vec<u8>, GitError>
Convert the Note to raw byte data for storage
§Returns
A Result containing the byte representation or an error
Source§fn from_buf_read_with_kind<R: BufRead>(
read: &mut ReadBoxed<R>,
size: usize,
kind: HashKind,
) -> Result<Self, GitError>where
Self: Sized,
fn from_buf_read_with_kind<R: BufRead>(
read: &mut ReadBoxed<R>,
size: usize,
kind: HashKind,
) -> Result<Self, GitError>where
Self: Sized,
ReadBoxed<BufRead> whose hasher was created
for kind (see ReadBoxed::new_with_kind). Read moreSource§fn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Selfwhere
Self: Sized,
fn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Selfwhere
Self: Sized,
ReadBoxed<BufRead>.
the input size,is only for new a vec with directive space allocation
the input data stream and output object should be plain base object . Read moreSource§fn object_hash_for_kind(&self, kind: HashKind) -> Result<ObjectHash, GitError>
fn object_hash_for_kind(&self, kind: HashKind) -> Result<ObjectHash, GitError>
kind. Read moreSource§fn object_hash(&self) -> Result<ObjectHash, GitError>
fn object_hash(&self) -> Result<ObjectHash, GitError>
Auto Trait Implementations§
impl Freeze for Note
impl RefUnwindSafe for Note
impl Send for Note
impl Sync for Note
impl Unpin for Note
impl UnsafeUnpin for Note
impl UnwindSafe for Note
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FileLoadStore for Twhere
T: Archive + for<'a> Serialize<Strategy<Serializer<AlignedVec, ArenaHandle<'a>, Share>, Error>>,
<T as Archive>::Archived: for<'a> CheckBytes<Strategy<Validator<ArchiveValidator<'a>, SharedValidator>, Error>> + Deserialize<T, Strategy<Pool, Error>>,
impl<T> FileLoadStore for Twhere
T: Archive + for<'a> Serialize<Strategy<Serializer<AlignedVec, ArenaHandle<'a>, Share>, Error>>,
<T as Archive>::Archived: for<'a> CheckBytes<Strategy<Validator<ArchiveValidator<'a>, SharedValidator>, Error>> + Deserialize<T, Strategy<Pool, Error>>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.