pub struct Note {
pub id: SHA1,
pub target_object_id: SHA1,
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: SHA1The SHA-1 hash of this Note object (same as the underlying Blob)
target_object_id: SHA1The SHA-1 hash of the object this Note annotates (usually a commit)
content: StringThe textual content of the Note
Implementations§
Source§impl Note
impl Note
Sourcepub fn from_content(content: &str) -> Self
pub fn from_content(content: &str) -> Self
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: SHA1)
pub fn set_target(&mut self, new_target: SHA1)
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 hash
Sourcepub fn from_bytes_with_target(
data: &[u8],
hash: SHA1,
target_object_id: SHA1,
) -> Result<Self, GitError>
pub fn from_bytes_with_target( data: &[u8], hash: SHA1, target_object_id: SHA1, ) -> 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 hash of this Note objecttarget_object_id- The SHA-1 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>, SHA1), GitError>
pub fn to_data_with_target(&self) -> Result<(Vec<u8>, SHA1), 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<'__de, __Context> BorrowDecode<'__de, __Context> for Note
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Note
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
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 ObjectTrait for Note
impl ObjectTrait for Note
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
impl Eq for Note
Auto Trait Implementations§
impl Freeze for Note
impl RefUnwindSafe for Note
impl Send for Note
impl Sync for Note
impl Unpin for Note
impl UnwindSafe for Note
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FileLoadStore for Twhere
T: Serialize + for<'a> Deserialize<'a>,
impl<T> FileLoadStore for Twhere
T: Serialize + for<'a> Deserialize<'a>,
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 more