pub enum ManagedString<'a, T>where
T: ArrayLength<u8>,{
Owned(String<T>),
Borrow(&'a str),
}Expand description
A borrowed or owned string
Basically like CoW, but with heapless::String
Variants§
Implementations§
Source§impl<'a, T> ManagedString<'a, T>where
T: ArrayLength<u8>,
impl<'a, T> ManagedString<'a, T>where
T: ArrayLength<u8>,
Sourcepub fn as_borrowed(&'a self) -> ManagedString<'a, T>
pub fn as_borrowed(&'a self) -> ManagedString<'a, T>
Retrieve a borrowed copy of the string
Sourcepub fn try_from_str(input: &str) -> Result<ManagedString<'static, T>, ()>
pub fn try_from_str(input: &str) -> Result<ManagedString<'static, T>, ()>
Attempt to create an Owned string from a given str
May fail if the heapless::String is not large enough to contain this slice
Sourcepub fn borrow_from_str(input: &str) -> ManagedString<'_, T>
pub fn borrow_from_str(input: &str) -> ManagedString<'_, T>
Create a Borrowed string from a given str
Sourcepub fn try_to_owned(&self) -> Result<ManagedString<'static, T>, ()>
pub fn try_to_owned(&self) -> Result<ManagedString<'static, T>, ()>
Attempt to convert to an Owned string from the current state
May fail if the heapless::String is not large enough to contain this slice
Trait Implementations§
Source§impl<'a, T> Clone for ManagedString<'a, T>
impl<'a, T> Clone for ManagedString<'a, T>
Source§fn clone(&self) -> ManagedString<'a, T>
fn clone(&self) -> ManagedString<'a, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T> Debug for ManagedString<'a, T>
impl<'a, T> Debug for ManagedString<'a, T>
Source§impl<'a, 'de, T> Deserialize<'de> for ManagedString<'a, T>where
'de: 'a,
T: ArrayLength<u8>,
impl<'a, 'de, T> Deserialize<'de> for ManagedString<'a, T>where
'de: 'a,
T: ArrayLength<u8>,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ManagedString<'a, T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ManagedString<'a, T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
We can deserialize as a borrowed str
Source§impl<'a, T> PartialEq for ManagedString<'a, T>
impl<'a, T> PartialEq for ManagedString<'a, T>
Source§impl<'a, T> Serialize for ManagedString<'a, T>where
T: ArrayLength<u8>,
impl<'a, T> Serialize for ManagedString<'a, T>where
T: ArrayLength<u8>,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
We can serialize our managed string as a str
impl<'a, T> Eq for ManagedString<'a, T>
impl<'a, T> StructuralPartialEq for ManagedString<'a, T>where
T: ArrayLength<u8>,
Auto Trait Implementations§
impl<'a, T> Freeze for ManagedString<'a, T>
impl<'a, T> RefUnwindSafe for ManagedString<'a, T>
impl<'a, T> Send for ManagedString<'a, T>
impl<'a, T> Sync for ManagedString<'a, T>
impl<'a, T> Unpin for ManagedString<'a, T>
impl<'a, T> UnwindSafe for ManagedString<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more