1use std::string::String;
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, PartialEq, Eq, Default)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9pub struct NeoString {
10 data: String,
11}
12
13impl NeoString {
14 pub fn new(data: String) -> Self {
15 Self { data }
16 }
17
18 #[allow(clippy::should_implement_trait)]
19 pub fn from_str(s: &str) -> Self {
20 Self {
21 data: String::from(s),
22 }
23 }
24
25 pub fn as_str(&self) -> &str {
26 &self.data
27 }
28
29 pub fn len(&self) -> usize {
30 self.data.len()
31 }
32
33 pub fn is_empty(&self) -> bool {
34 self.data.is_empty()
35 }
36}
37
38impl From<&str> for NeoString {
39 fn from(s: &str) -> Self {
40 Self::from_str(s)
41 }
42}
43
44impl From<String> for NeoString {
45 fn from(data: String) -> Self {
46 Self { data }
47 }
48}