gix_object/tag/
mod.rs

1use winnow::prelude::*;
2
3use crate::TagRef;
4
5mod decode;
6
7///
8pub mod write;
9
10///
11pub mod ref_iter;
12
13impl<'a> TagRef<'a> {
14    /// Deserialize a tag from `data`.
15    pub fn from_bytes(mut data: &'a [u8]) -> Result<TagRef<'a>, crate::decode::Error> {
16        let input = &mut data;
17        match decode::git_tag.parse_next(input) {
18            Ok(tag) => Ok(tag),
19            Err(err) => Err(crate::decode::Error::with_err(err, input)),
20        }
21    }
22    /// The object this tag points to as `Id`.
23    pub fn target(&self) -> gix_hash::ObjectId {
24        gix_hash::ObjectId::from_hex(self.target).expect("prior validation")
25    }
26
27    /// Copy all data into a fully-owned instance.
28    pub fn into_owned(self) -> crate::Tag {
29        self.into()
30    }
31}