pub enum Text {
String(String),
StaticStr(&'static str),
}Variants§
String(String)
Represents a dynamically allocated string.
StaticStr(&'static str)
Represents a statically allocated string slice.
Implementations§
Source§impl Text
impl Text
pub fn new<S: Into<String>>(s: S) -> Self
pub fn len(&self) -> usize
pub fn to_uppercase(&self) -> Text
pub fn to_lowercase(&self) -> Text
pub fn as_str(&self) -> &str
pub fn try_as_mut_str(&mut self) -> Option<&mut str>
Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Converts the Text into a String, cloning the inner string if necessary.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Converts the Text into a String, consuming the Text in the process. If the Text is a StaticStr variant, it will allocate a new String from the static string slice.
pub fn char_at(&self, index: u32) -> Result<char, IndexOutOfBoundsError>
pub fn substring(&self, start: usize, end: usize) -> Option<Text>
pub fn contains(&self, substring: &str) -> bool
pub fn starts_with(&self, prefix: &str) -> bool
pub fn ends_with(&self, suffix: &str) -> bool
pub fn index_of(&self, substring: &str) -> Option<usize>
pub fn last_index_of(&self, substring: &str) -> Option<usize>
pub fn is_empty(&self) -> bool
pub fn trim(&self) -> Text
pub fn trim_start(&self) -> Text
pub fn split(&self, delimiter: &str) -> Vec<Text>
pub fn join(texts: &[Text], separator: &str) -> Text
pub fn repeat(&self, n: usize) -> Text
Source§impl Text
impl Text
Sourcepub fn try_as_mut_string(&mut self) -> Result<&mut String, ()>
pub fn try_as_mut_string(&mut self) -> Result<&mut String, ()>
Returns a mutable reference to the inner String if the Text is a String variant, otherwise returns an error. This allows for modifying the inner String directly, but will fail if the Text is a StaticStr variant.
pub fn clear(&mut self) -> Result<(), ()>
pub fn reverse(&mut self) -> Result<(), ()>
pub fn push_str(&mut self, s: &str) -> Result<(), ()>
pub fn push_char(&mut self, c: char) -> Result<(), ()>
pub fn pop_char(&mut self) -> Result<Option<char>, ()>
Sourcepub fn insert(&mut self, index: usize, s: &str) -> Result<(), ()>
pub fn insert(&mut self, index: usize, s: &str) -> Result<(), ()>
Inserts a string slice at the specified index in the Text. Returns an error if the Text is a StaticStr variant or if the index is out of bounds.
pub fn remove(&mut self, index: usize) -> Result<char, ()>
pub fn replace(&mut self, from: &str, to: &str) -> Result<(), ()>
pub fn replace_range( &mut self, range: Range<usize>, replace_with: &str, ) -> Result<(), ()>
pub fn set_char_at(&mut self, index: u32, c: char) -> Result<(), SetCharAtError>
Trait Implementations§
Source§impl AddAssign for Text
Allow TypedDatexValue += String and TypedDatexValue += &str
This can never panic since the Text::from from string will always succeed
impl AddAssign for Text
Allow TypedDatexValue
Source§fn add_assign(&mut self, rhs: Text)
fn add_assign(&mut self, rhs: Text)
+= operation. Read moreSource§impl BinRead for Text
impl BinRead for Text
Source§fn read_options<R: Read + Seek>(
reader: &mut R,
endian: Endian,
args: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( reader: &mut R, endian: Endian, args: Self::Args<'_>, ) -> BinResult<Self>
Source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
big-endian byte order. Read moreSource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
little-endian byte order. Read moreSource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T from the reader assuming native-endian byte order. Read moreSource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader, assuming big-endian byte order, using the
given arguments. Read moreSource§impl BinWrite for Text
impl BinWrite for Text
Source§fn write_options<W: Write + Seek>(
&self,
writer: &mut W,
endian: Endian,
args: Self::Args<'_>,
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, writer: &mut W, endian: Endian, args: Self::Args<'_>, ) -> BinResult<()>
Source§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming big-endian byte order. Read moreSource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming little-endian byte order. Read moreSource§fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming native-endian byte order. Read moreSource§fn write_be_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self to the writer, assuming big-endian byte order, using the
given arguments. Read moreSource§impl Classification for Text
impl Classification for Text
Source§fn entity_type(&self, _cache: &mut SharedReferencesCache) -> Option<EntityType>
fn entity_type(&self, _cache: &mut SharedReferencesCache) -> Option<EntityType>
Source§fn entity_type_address(&self) -> Option<PointerAddress>
fn entity_type_address(&self) -> Option<PointerAddress>
Source§fn tag(&self) -> Option<ValueTag>
fn tag(&self) -> Option<ValueTag>
Source§fn impls(&self) -> Vec<PointerAddress>
fn impls(&self) -> Vec<PointerAddress>
Source§fn classification(
&self,
cache: &mut SharedReferencesCache,
) -> ValueClassification
fn classification( &self, cache: &mut SharedReferencesCache, ) -> ValueClassification
Source§fn unresolved_classification(&self) -> UnresolvedValueClassification
fn unresolved_classification(&self) -> UnresolvedValueClassification
Source§impl ConvertValue for Text
impl ConvertValue for Text
fn to_value(self) -> Value
fn try_from_value(value: Value) -> Result<Self, Value>
fn try_borrow_from_value(value: &Value) -> Result<&Text, ()>
fn try_borrow_mut_from_value(value: &mut Value) -> Result<&mut Text, ()>
Source§impl DatexHash for Text
impl DatexHash for Text
fn datex_hash(&self, state: &mut dyn Hasher)
fn datex_hash_default(&self) -> u64
Source§impl DatexNative for Text
impl DatexNative for Text
impl DatexNativeOnlyStructural for Text
Source§impl DatexNativeOps for Text
impl DatexNativeOps for Text
fn add_native(&self, _rhs: &dyn DatexNative) -> Option<Box<dyn DatexNative>>
Source§impl DatexNativeStructural for Text
impl DatexNativeStructural for Text
Source§fn classification_without_cache(&self) -> ValueClassification
fn classification_without_cache(&self) -> ValueClassification
Source§impl<'de> DeserializeWithSerdeContext<'de> for Text
impl<'de> DeserializeWithSerdeContext<'de> for Text
fn deserialize_with_ctx<D: Deserializer<'de>>( _ctx: &SerdeContext<'_>, deserializer: D, ) -> Result<Self, D::Error>
impl Eq for Text
Source§impl From<&'static str> for Text
The froms are used for this magic. This will automatically convert
the Rust types to Text when using the += operator.
impl From<&'static str> for Text
The froms are used for this magic. This will automatically convert the Rust types to Text when using the += operator.
Source§impl From<Text> for LiteralTypeDefinition
impl From<Text> for LiteralTypeDefinition
Source§impl FromParts for Text
impl FromParts for Text
fn try_from_single_value_with_tag(
value: ValueContainer,
_tag: Option<&str>,
) -> Result<Self, ()>where
Self: Sized,
Source§fn try_from_map_parts(_parts: Map) -> Result<Self, ()>where
Self: Sized,
fn try_from_map_parts(_parts: Map) -> Result<Self, ()>where
Self: Sized,
Source§fn try_from_list_parts(_parts: List) -> Result<Self, ()>where
Self: Sized,
fn try_from_list_parts(_parts: List) -> Result<Self, ()>where
Self: Sized,
Source§fn try_from_single_value(_value: ValueContainer) -> Result<Self, ()>where
Self: Sized,
fn try_from_single_value(_value: ValueContainer) -> Result<Self, ()>where
Self: Sized,
fn try_from_map_parts_with_tag(
_parts: Map,
_tag: Option<&str>,
) -> Result<Self, ()>where
Self: Sized,
fn try_from_list_parts_with_tag(
_parts: List,
_tag: Option<&str>,
) -> Result<Self, ()>where
Self: Sized,
Source§impl GetCoreLibTypeId for Text
impl GetCoreLibTypeId for Text
fn core_lib_type_id(&self) -> CoreLibTypeId
Source§impl GetDatexType for Text
impl GetDatexType for Text
fn datex_type(_context: &mut SharedReferencesCache) -> Type
Source§impl HasPartsKind for Text
impl HasPartsKind for Text
Source§fn parts_kind(&self) -> PartsKind
fn parts_kind(&self) -> PartsKind
PartsKind::None, then the conversion is not possible.
If this returns PartsKind::List, then the conversion is possible and try_into_list_parts() can be called.
If this returns PartsKind::Map, then the conversion is possible and try_into_map_parts() can be called.
If this returns PartsKind::SingleValue, then the conversion is possible and try_from_single_value() can be called.Source§impl IntoParts for Text
Default implementations - cannot be split into parts
impl IntoParts for Text
Default implementations - cannot be split into parts
Source§fn try_into_single_value<'a>(self: Box<Self>) -> Result<ValueContainer, ()>where
Self: 'a,
fn try_into_single_value<'a>(self: Box<Self>) -> Result<ValueContainer, ()>where
Self: 'a,
parts_kind()
and checking if it returns PartsKind::SingleValue.Source§fn try_into_map_parts<'a>(self: Box<Self>) -> Result<Map, ()>where
Self: 'a,
fn try_into_map_parts<'a>(self: Box<Self>) -> Result<Map, ()>where
Self: 'a,
parts_kind()
and checking if it returns PartsKind::Map.Source§fn try_into_list_parts<'a>(self: Box<Self>) -> Result<List, ()>where
Self: 'a,
fn try_into_list_parts<'a>(self: Box<Self>) -> Result<List, ()>where
Self: 'a,
parts_kind()
and checking if it returns PartsKind::List.Source§impl IterParts for Text
impl IterParts for Text
fn iter_parts<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = BorrowedValueContainer<'a>> + 'a>>
fn iter_list_parts<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = BorrowedValueContainer<'a>> + 'a>>
fn iter_list_parts_mut<'a>( &'a mut self, ) -> Option<Box<dyn Iterator<Item = BorrowedValueContainerMut<'a>> + 'a>>
fn iter_map_parts<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = (BorrowedValueContainer<'a>, BorrowedValueContainer<'a>)> + 'a>>
fn iter_map_parts_mut<'a>( &'a mut self, ) -> Option<Box<dyn Iterator<Item = (BorrowedValueContainer<'a>, BorrowedValueContainerMut<'a>)> + 'a>>
Source§impl LocalChildPathResolver for Text
impl LocalChildPathResolver for Text
fn resolve_child( &mut self, _key: &ValueContainer, ) -> Result<&mut ValueContainer, UpdateError>
fn resolve_value_for_path( &mut self, first: &ValueContainer, remaining_path: &[ValueContainer], ) -> Result<&mut Value, UpdateError>
Source§impl SerializeWithSerdeContext for Text
impl SerializeWithSerdeContext for Text
fn serialize_with_ctx<S: Serializer>( &self, ctx: &SerdeContext<'_>, serializer: S, ) -> Result<S::Ok, S::Error>
Source§impl StructuralEq for Text
impl StructuralEq for Text
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
Source§impl ToInstructions for Text
impl ToInstructions for Text
fn to_instructions( &self, visitor: &mut dyn ValueVisitor, cache: &mut SharedReferencesCache, ) -> Box<dyn Iterator<Item = Instruction>>
Source§impl UpdateCallbackDataAccess for Text
impl UpdateCallbackDataAccess for Text
fn get_update_callback_data(&self) -> Option<&UpdateCallbackData>
Source§impl UpdateHandlerImpl for Text
impl UpdateHandlerImpl for Text
Source§fn try_update(
&mut self,
operation: UpdateOperation,
source_id: Option<TransceiverId>,
cache: &RefCell<SharedReferencesCache>,
) -> UpdateResult
fn try_update( &mut self, operation: UpdateOperation, source_id: Option<TransceiverId>, cache: &RefCell<SharedReferencesCache>, ) -> UpdateResult
fn try_set_entry( &mut self, _data: SetEntryUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>
fn try_delete_entry( &mut self, _data: DeleteEntryUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>
fn try_append_entry( &mut self, _data: AppendEntryUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_clear( &mut self, _cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>
fn try_list_splice( &mut self, _data: ListSpliceUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<Vec<ValueContainer>, UpdateError>
fn try_increment( &mut self, _data: IncrementUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_decrement( &mut self, _data: DecrementUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_replace( &mut self, _data: ReplaceUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
Source§impl ValueAccess for Text
impl ValueAccess for Text
Source§fn try_get_property(
&self,
_key: &ValueContainer,
) -> Result<BorrowedValueContainer<'_>, AccessError>
fn try_get_property( &self, _key: &ValueContainer, ) -> Result<BorrowedValueContainer<'_>, AccessError>
Source§fn try_get_property_mut(
&mut self,
_key: &ValueContainer,
) -> Result<BorrowedValueContainerMut<'_>, AccessError>
fn try_get_property_mut( &mut self, _key: &ValueContainer, ) -> Result<BorrowedValueContainerMut<'_>, AccessError>
Auto Trait Implementations§
impl Forget for Text
impl Freeze for Text
impl Move for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ConvertValueContainer for T
impl<T> ConvertValueContainer for T
Source§fn to_value_container(self) -> ValueContainer
fn to_value_container(self) -> ValueContainer
Source§fn as_borrowed_value_container(&self) -> BorrowedValueContainer<'_>
fn as_borrowed_value_container(&self) -> BorrowedValueContainer<'_>
Source§fn as_borrowed_value_container_mut(&mut self) -> BorrowedValueContainerMut<'_>
fn as_borrowed_value_container_mut(&mut self) -> BorrowedValueContainerMut<'_>
Source§fn try_from_value_container(
value_container: ValueContainer,
) -> Result<T, ValueContainer>where
T: Sized,
fn try_from_value_container(
value_container: ValueContainer,
) -> Result<T, ValueContainer>where
T: Sized,
Source§fn try_convert_from_value_container(
value_container: ValueContainer,
) -> Result<T, ()>
fn try_convert_from_value_container( value_container: ValueContainer, ) -> Result<T, ()>
Source§fn try_borrow_from_value_container(
value_container: &ValueContainer,
) -> Result<&T, ()>where
T: Sized,
fn try_borrow_from_value_container(
value_container: &ValueContainer,
) -> Result<&T, ()>where
T: Sized,
Source§fn try_borrow_mut_from_value_container(
value_container: &mut ValueContainer,
) -> Result<&mut T, ()>where
T: Sized,
fn try_borrow_mut_from_value_container(
value_container: &mut ValueContainer,
) -> Result<&mut T, ()>where
T: Sized,
Source§fn try_from_bytes(
dxb: Vec<u8>,
runtime: &Runtime,
) -> Result<Self, DeserializationError>
fn try_from_bytes( dxb: Vec<u8>, runtime: &Runtime, ) -> Result<Self, DeserializationError>
Source§impl<T> CustomError for T
impl<T> CustomError for T
impl<T> DatexNativeBase for T
Source§impl<T> DeserializeWithSerdeContextDyn for Twhere
T: for<'de> DeserializeWithSerdeContext<'de>,
impl<T> DeserializeWithSerdeContextDyn for Twhere
T: for<'de> DeserializeWithSerdeContext<'de>,
fn deserialize_with_ctx_dyn<'de>( ctx: &SerdeContext<'_>, deserializer: &mut dyn Deserializer<'de>, ) -> Result<T, Error>
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
key and return true if they are equal.Source§impl<T> GetAllowedType for Twhere
T: GetDatexType,
impl<T> GetAllowedType for Twhere
T: GetDatexType,
fn allowed_type(&self, cache: &mut SharedReferencesCache) -> TypeDefinition
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more