use crate::util::Binding;
use crate::{raw, Oid};
use std::marker;
use std::str;
pub struct PushUpdate<'a> {
raw: *const raw::git_push_update,
_marker: marker::PhantomData<&'a raw::git_push_update>,
}
impl<'a> Binding for PushUpdate<'a> {
type Raw = *const raw::git_push_update;
unsafe fn from_raw(raw: *const raw::git_push_update) -> PushUpdate<'a> {
PushUpdate {
raw,
_marker: marker::PhantomData,
}
}
fn raw(&self) -> Self::Raw {
self.raw
}
}
impl PushUpdate<'_> {
pub fn src_refname_bytes(&self) -> &[u8] {
unsafe { crate::opt_bytes(self, (*self.raw).src_refname).unwrap() }
}
pub fn src_refname(&self) -> Option<&str> {
str::from_utf8(self.src_refname_bytes()).ok()
}
pub fn dst_refname_bytes(&self) -> &[u8] {
unsafe { crate::opt_bytes(self, (*self.raw).dst_refname).unwrap() }
}
pub fn dst_refname(&self) -> Option<&str> {
str::from_utf8(self.dst_refname_bytes()).ok()
}
pub fn src(&self) -> Oid {
unsafe { Binding::from_raw(&(*self.raw).src as *const _) }
}
pub fn dst(&self) -> Oid {
unsafe { Binding::from_raw(&(*self.raw).dst as *const _) }
}
}