pub struct BoundedText<const MAX: usize>(/* private fields */);Expand description
Non-blank text of at most MAX UTF-8 bytes.
Deserializes from a TOML string and rejects a blank or over-long value at load time. The cap counts bytes, not chars.
§Examples
use mcpls_core::config::BoundedText;
let text = BoundedText::<8>::new("hello").unwrap();
assert_eq!(text.as_str(), "hello");
assert!(BoundedText::<8>::new(" ").is_err());
assert!(BoundedText::<8>::new("123456789").is_err());Implementations§
Source§impl<const MAX: usize> BoundedText<MAX>
impl<const MAX: usize> BoundedText<MAX>
Sourcepub fn new(text: impl Into<String>) -> Result<Self, InvalidBoundedText>
pub fn new(text: impl Into<String>) -> Result<Self, InvalidBoundedText>
Builds the text from any string.
§Errors
Returns InvalidBoundedText::Blank before InvalidBoundedText::TooLong,
so a whitespace-only value reports as blank.
Trait Implementations§
Source§impl<const MAX: usize> Clone for BoundedText<MAX>
impl<const MAX: usize> Clone for BoundedText<MAX>
Source§impl<const MAX: usize> Debug for BoundedText<MAX>
impl<const MAX: usize> Debug for BoundedText<MAX>
Source§impl<'de, const MAX: usize> Deserialize<'de> for BoundedText<MAX>
impl<'de, const MAX: usize> Deserialize<'de> for BoundedText<MAX>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const MAX: usize> Display for BoundedText<MAX>
impl<const MAX: usize> Display for BoundedText<MAX>
impl<const MAX: usize> Eq for BoundedText<MAX>
Source§impl<const MAX: usize> From<BoundedText<MAX>> for String
impl<const MAX: usize> From<BoundedText<MAX>> for String
Source§fn from(value: BoundedText<MAX>) -> Self
fn from(value: BoundedText<MAX>) -> Self
Converts to this type from the input type.
Source§impl<const MAX: usize> FromStr for BoundedText<MAX>
impl<const MAX: usize> FromStr for BoundedText<MAX>
Source§impl<const MAX: usize> Hash for BoundedText<MAX>
impl<const MAX: usize> Hash for BoundedText<MAX>
Source§impl<const MAX: usize> PartialEq for BoundedText<MAX>
impl<const MAX: usize> PartialEq for BoundedText<MAX>
Source§impl<const MAX: usize> Serialize for BoundedText<MAX>
impl<const MAX: usize> Serialize for BoundedText<MAX>
impl<const MAX: usize> StructuralPartialEq for BoundedText<MAX>
Auto Trait Implementations§
impl<const MAX: usize> Freeze for BoundedText<MAX>
impl<const MAX: usize> RefUnwindSafe for BoundedText<MAX>
impl<const MAX: usize> Send for BoundedText<MAX>
impl<const MAX: usize> Sync for BoundedText<MAX>
impl<const MAX: usize> Unpin for BoundedText<MAX>
impl<const MAX: usize> UnsafeUnpin for BoundedText<MAX>
impl<const MAX: usize> UnwindSafe for BoundedText<MAX>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.