use core::ffi::CStr;
use crate::furi::string::FuriString;
#[repr(transparent)]
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct Path(CStr);
impl Path {
pub fn new<S: AsRef<CStr> + ?Sized>(s: &S) -> &Self {
let s: &CStr = s.as_ref();
unsafe { core::mem::transmute(s) }
}
pub fn as_c_str(&self) -> &CStr {
&self.0
}
}
impl Default for &Path {
fn default() -> Self {
Path::new(c"")
}
}
impl AsRef<Path> for &Path {
fn as_ref(&self) -> &Path {
self
}
}
impl AsRef<CStr> for Path {
fn as_ref(&self) -> &CStr {
self.as_c_str()
}
}
impl AsRef<Path> for CStr {
fn as_ref(&self) -> &Path {
Path::new(self)
}
}
impl AsRef<Path> for FuriString {
fn as_ref(&self) -> &Path {
Path::new(self.as_c_str())
}
}