use core::borrow::Borrow;
use core::fmt;
use core::hash;
use core::ops::Deref;
use alloc::vec::Vec;
use super::ObjectPath;
#[derive(Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct ObjectPathBuf(Vec<u8>);
impl ObjectPathBuf {
#[inline]
pub(super) unsafe fn from_raw_vec(data: Vec<u8>) -> Self {
Self(data)
}
#[inline]
fn to_object_path(&self) -> &ObjectPath {
unsafe { ObjectPath::new_unchecked(&self.0) }
}
}
impl hash::Hash for ObjectPathBuf {
#[inline]
fn hash<H>(&self, state: &mut H)
where
H: hash::Hasher,
{
hash::Hash::hash(&**self, state);
}
}
impl fmt::Display for ObjectPathBuf {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
impl fmt::Debug for ObjectPathBuf {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
}
impl Deref for ObjectPathBuf {
type Target = ObjectPath;
#[inline]
fn deref(&self) -> &Self::Target {
self.to_object_path()
}
}
impl Borrow<ObjectPath> for ObjectPathBuf {
#[inline]
fn borrow(&self) -> &ObjectPath {
self
}
}
impl AsRef<ObjectPath> for ObjectPathBuf {
#[inline]
fn as_ref(&self) -> &ObjectPath {
self
}
}