1use crate::util::Binding;
2use crate::{raw, Oid};
3use std::marker;
4use std::str;
5
6pub struct PushUpdate<'a> {
8 raw: *const raw::git_push_update,
9 _marker: marker::PhantomData<&'a raw::git_push_update>,
10}
11
12impl<'a> Binding for PushUpdate<'a> {
13 type Raw = *const raw::git_push_update;
14 unsafe fn from_raw(raw: *const raw::git_push_update) -> PushUpdate<'a> {
15 PushUpdate {
16 raw,
17 _marker: marker::PhantomData,
18 }
19 }
20 fn raw(&self) -> Self::Raw {
21 self.raw
22 }
23}
24
25impl PushUpdate<'_> {
26 pub fn src_refname_bytes(&self) -> &[u8] {
28 unsafe { crate::opt_bytes(self, (*self.raw).src_refname).unwrap() }
29 }
30
31 pub fn src_refname(&self) -> Option<&str> {
33 str::from_utf8(self.src_refname_bytes()).ok()
34 }
35
36 pub fn dst_refname_bytes(&self) -> &[u8] {
38 unsafe { crate::opt_bytes(self, (*self.raw).dst_refname).unwrap() }
39 }
40
41 pub fn dst_refname(&self) -> Option<&str> {
43 str::from_utf8(self.dst_refname_bytes()).ok()
44 }
45
46 pub fn src(&self) -> Oid {
48 unsafe { Binding::from_raw(&(*self.raw).src as *const _) }
49 }
50
51 pub fn dst(&self) -> Oid {
53 unsafe { Binding::from_raw(&(*self.raw).dst as *const _) }
54 }
55}