1use crate::parse::parse_signature;
2use crate::TagRef;
3use winnow::prelude::*;
4
5mod decode;
6
7pub mod write;
9
10pub mod ref_iter;
12
13impl<'a> TagRef<'a> {
14 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 pub fn target(&self) -> gix_hash::ObjectId {
24 gix_hash::ObjectId::from_hex(self.target).expect("prior validation")
25 }
26
27 pub fn tagger(&self) -> Result<Option<gix_actor::SignatureRef<'a>>, crate::decode::Error> {
29 Ok(self
30 .tagger
31 .map(parse_signature)
32 .transpose()?
33 .map(|signature| signature.trim()))
34 }
35
36 pub fn into_owned(self) -> Result<crate::Tag, crate::decode::Error> {
38 self.try_into()
39 }
40}