git_object/tag/mod.rs
1use crate::TagRef;
2
3mod decode;
4
5///
6pub mod write;
7
8///
9pub mod ref_iter;
10
11impl<'a> TagRef<'a> {
12 /// Deserialize a tag from `data`.
13 pub fn from_bytes(data: &'a [u8]) -> Result<TagRef<'a>, crate::decode::Error> {
14 decode::git_tag(data)
15 .map(|(_, t)| t)
16 .map_err(crate::decode::Error::from)
17 }
18 /// The object this tag points to as `Id`.
19 pub fn target(&self) -> git_hash::ObjectId {
20 git_hash::ObjectId::from_hex(self.target).expect("prior validation")
21 }
22}