use std::borrow::Borrow;
use std::ops::Deref;
use crate::ngstr::prelude::*;
#[derive(PartialEq, Eq, Clone, Default)]
pub struct Cesu8String {
pub(crate) inner: Vec<u8>,
}
impl Cesu8String {
impl_string_encoding_meths!(base, "CESU-8");
impl_string_encoding_meths!(string, "CESU-8");
}
impl Cesu8String {
pub(crate) const unsafe fn _from_bytes_unchecked(b: Vec<u8>) -> Self {
Cesu8String { inner: b }
}
pub(crate) const fn _into_bytes_unchecked(self) -> Vec<u8> {
let this = std::mem::ManuallyDrop::new(self);
unsafe { std::ptr::read(&this.inner) }
}
}
impl Borrow<Cesu8Str> for Cesu8String {
fn borrow(&self) -> &Cesu8Str {
self
}
}
impl Deref for Cesu8String {
type Target = Cesu8Str;
fn deref(&self) -> &Self::Target {
unsafe { Self::Target::_from_bytes_unchecked(&self.inner) }
}
}