1use crate::parse::parse_signature;
2use crate::TagRef;
3
4mod decode;
5
6pub mod write;
8
9pub mod ref_iter;
11
12impl<'a> TagRef<'a> {
13 pub fn from_bytes(mut data: &'a [u8], hash_kind: gix_hash::Kind) -> Result<TagRef<'a>, crate::decode::Error> {
15 let input = &mut data;
16 match decode::git_tag(input, hash_kind) {
17 Ok(tag) => Ok(tag),
18 Err(err) => Err(err),
19 }
20 }
21 pub fn target(&self) -> gix_hash::ObjectId {
23 gix_hash::ObjectId::from_hex(self.target).expect("prior validation")
24 }
25
26 pub fn tagger(&self) -> Result<Option<gix_actor::SignatureRef<'a>>, crate::decode::Error> {
28 Ok(self
29 .tagger
30 .map(parse_signature)
31 .transpose()?
32 .map(|signature| signature.trim()))
33 }
34
35 pub fn into_owned(self) -> Result<crate::Tag, crate::decode::Error> {
37 self.try_into()
38 }
39}