Struct gdnative_core::core_types::string::GodotString [−][src]
Godot's reference-counted string type.
This is the Rust binding of GDScript's String
type. It represents the native string class
used within the Godot engine, and as such has different memory layout and characteristics than
std::string::String
.
GodotString
is reference-counted like most types in godot-rust. Thus, its clone()
method
does not return a copy of the string, but simply another instance which shares the same backing
string. Furthermore, GodotString
is immutable and does not offer any write APIs. If you need
to modify Godot strings, convert them to Rust strings, perform the modifications and convert back.
In GDScript, strings have copy-on-write semantics, which guarantees that GodotString
instances
in Rust are independent of their GDScript counterparts. A modification of a string in GDScript
(which was previously passed to Rust) will not be reflected in Rust.
When interfacing with the Godot engine API through godot-rust, you often have the choice between
std::string::String
and gdnative::core_types::GodotString
. In user methods that are exposed to
Godot through the #[export]
macro, both types can be used as parameters and return types, and any
conversions are done transparently.
For auto-generated binding APIs in gdnative::api
, return types are GodotString
, but parameters
are declared impl Into<GodotString>
, allowing String
or &str
to be passed. In addition, the
two types can always be explicitly converted using GodotString::from_str()
and
GodotString::display/to_string()
.
As a general guideline, use GodotString
if:
- your strings are very large, so you can avoid copying them
- you need specific operations only available in Godot (e.g.
sha256_text()
,c_escape()
, ...) - you primarily pass them between different Godot APIs, without string processing in user code
Use Rust's String
if:
- you need to modify the string
- you would like to decouple part of your code from Godot (e.g. independent game logic, standalone tests)
- you want a standard type for interoperability with third-party code (e.g.
regex
crate) - you have a large number of method calls per string instance (which are more expensive due to indirectly calling into Godot)
- you need UTF-8 encoding (
GodotString
's encoding is platform-dependent and unspecified)
Implementations
impl GodotString
[src]
pub fn new() -> Self
[src]
pub fn from_str<S>(s: S) -> Self where
S: AsRef<str>,
[src]
S: AsRef<str>,
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn is_numeric(&self) -> bool
[src]
pub fn is_valid_float(&self) -> bool
[src]
pub fn is_valid_html_color(&self) -> bool
[src]
pub fn is_valid_identifier(&self) -> bool
[src]
pub fn is_valid_integer(&self) -> bool
[src]
pub fn is_valid_ip_address(&self) -> bool
[src]
pub fn is_resource_file(&self) -> bool
[src]
pub fn is_absolute_path(&self) -> bool
[src]
pub fn is_relative_path(&self) -> bool
[src]
pub fn to_f32(&self) -> f32
[src]
pub fn to_f64(&self) -> f64
[src]
pub fn to_i32(&self) -> i32
[src]
pub fn u32_hash(&self) -> u32
[src]
pub fn u64_hash(&self) -> u64
[src]
pub fn hex_to_int(&self) -> i32
[src]
pub fn hex_to_int_without_prefix(&self) -> i32
[src]
pub fn camelcase_to_underscore(&self) -> Self
[src]
pub fn camelcase_to_underscore_lowercased(&self) -> Self
[src]
pub fn capitalize(&self) -> Self
[src]
pub fn to_lowercase(&self) -> Self
[src]
pub fn to_uppercase(&self) -> Self
[src]
pub fn get_file(&self) -> Self
[src]
pub fn get_base_dir(&self) -> Self
[src]
pub fn get_basename(&self) -> Self
[src]
pub fn get_extension(&self) -> Self
[src]
pub fn simplify_path(&self) -> Self
[src]
pub fn sha256_text(&self) -> Self
[src]
pub fn md5_text(&self) -> Self
[src]
pub fn c_escape(&self) -> Self
[src]
pub fn c_escape_multiline(&self) -> Self
[src]
pub fn c_unescape(&self) -> Self
[src]
pub fn http_escape(&self) -> Self
[src]
pub fn http_unescape(&self) -> Self
[src]
pub fn json_escape(&self) -> Self
[src]
pub fn xml_escape(&self) -> Self
[src]
pub fn xml_escape_with_quotes(&self) -> Self
[src]
pub fn xml_unescape(&self) -> Self
[src]
pub fn percent_decode(&self) -> Self
[src]
pub fn percent_encode(&self) -> Self
[src]
pub fn is_valid_hex_number(&self, with_prefix: bool) -> bool
[src]
pub fn begins_with(&self, s: &GodotString) -> bool
[src]
pub fn ends_with(&self, s: &GodotString) -> bool
[src]
pub fn begins_with_c_str(&self, s: &CStr) -> bool
[src]
pub fn sub_string(&self, range: Range<usize>) -> Self
[src]
pub fn find(&self, what: &GodotString) -> i32
[src]
pub fn find_from(&self, what: &GodotString, from: i32) -> i32
[src]
pub fn find_last(&self, what: &GodotString) -> i32
[src]
Trait Implementations
impl Add<&'_ GodotString> for &GodotString
[src]
type Output = GodotString
The resulting type after applying the +
operator.
fn add(self, other: &GodotString) -> GodotString
[src]
impl Add<GodotString> for GodotString
[src]
type Output = GodotString
The resulting type after applying the +
operator.
fn add(self, other: GodotString) -> GodotString
[src]
impl<S> Add<S> for &GodotString where
S: AsRef<str>,
[src]
S: AsRef<str>,
type Output = GodotString
The resulting type after applying the +
operator.
fn add(self, other: S) -> GodotString
[src]
impl AddAssign<&'_ GodotString> for GodotString
[src]
AddAssign
implementations copy the strings' contents since GodotString
is immutable.
fn add_assign(&mut self, other: &Self)
[src]
impl AddAssign<GodotString> for GodotString
[src]
AddAssign
implementations copy the strings' contents since GodotString
is immutable.
fn add_assign(&mut self, other: Self)
[src]
impl<S> AddAssign<S> for GodotString where
S: AsRef<str>,
[src]
S: AsRef<str>,
AddAssign
implementations copy the strings' contents since GodotString
is immutable.
fn add_assign(&mut self, other: S)
[src]
impl Clone for GodotString
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for GodotString
[src]
impl Default for GodotString
[src]
impl Display for GodotString
[src]
impl Drop for GodotString
[src]
impl Element for GodotString
[src]
type SysArray = godot_pool_string_array
type SysReadAccess = godot_pool_string_array_read_access
type SysWriteAccess = godot_pool_string_array_write_access
type SysTy = godot_string
type SysRefTy = *const godot_string
const SYS_VARIANT_TYPE: godot_variant_type
[src]
fn element_to_sys(self) -> Self::SysTy
[src]
fn element_from_sys(sys: Self::SysTy) -> Self
[src]
fn element_to_sys_ref(&self) -> Self::SysRefTy
[src]
unsafe fn element_from_sys_ref(sys: Self::SysRefTy) -> Self
[src]
fn array_to_variant_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut godot_variant, _: *const Self::SysArray)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut godot_variant, _: *const Self::SysArray)
fn array_from_variant_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const godot_variant) -> Self::SysArray
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const godot_variant) -> Self::SysArray
fn new_fn(api: &GodotApi) -> unsafe extern "C" fn(_: *mut Self::SysArray)
[src]
fn new_copy_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: *const Self::SysArray)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: *const Self::SysArray)
fn new_with_array_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: *const godot_array)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: *const godot_array)
fn append_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: Self::SysRefTy)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: Self::SysRefTy)
fn append_array_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: *const Self::SysArray)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: *const Self::SysArray)
fn insert_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int, _: Self::SysRefTy) -> godot_error
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int, _: Self::SysRefTy) -> godot_error
fn invert_fn(api: &GodotApi) -> unsafe extern "C" fn(_: *mut Self::SysArray)
[src]
fn push_back_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: Self::SysRefTy)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: Self::SysRefTy)
fn remove_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int)
fn resize_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int)
fn read_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysArray) -> *mut Self::SysReadAccess
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysArray) -> *mut Self::SysReadAccess
fn write_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray) -> *mut Self::SysWriteAccess
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray) -> *mut Self::SysWriteAccess
fn set_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int, _: Self::SysRefTy)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysArray, _: godot_int, _: Self::SysRefTy)
fn get_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysArray, _: godot_int) -> Self::SysTy
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysArray, _: godot_int) -> Self::SysTy
fn size_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysArray) -> godot_int
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysArray) -> godot_int
fn destroy_fn(api: &GodotApi) -> unsafe extern "C" fn(_: *mut Self::SysArray)
[src]
fn read_access_copy_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysReadAccess) -> *mut Self::SysReadAccess
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysReadAccess) -> *mut Self::SysReadAccess
fn read_access_ptr_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysReadAccess) -> *const Self::SysTy
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysReadAccess) -> *const Self::SysTy
fn read_access_operator_assign_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysReadAccess, _: *mut Self::SysReadAccess)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysReadAccess, _: *mut Self::SysReadAccess)
fn read_access_destroy_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysReadAccess)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysReadAccess)
fn write_access_copy_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysWriteAccess) -> *mut Self::SysWriteAccess
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysWriteAccess) -> *mut Self::SysWriteAccess
fn write_access_ptr_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysWriteAccess) -> *mut Self::SysTy
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *const Self::SysWriteAccess) -> *mut Self::SysTy
fn write_access_operator_assign_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysWriteAccess, _: *mut Self::SysWriteAccess)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysWriteAccess, _: *mut Self::SysWriteAccess)
fn write_access_destroy_fn(
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysWriteAccess)
[src]
api: &GodotApi
) -> unsafe extern "C" fn(_: *mut Self::SysWriteAccess)
impl Eq for GodotString
[src]
impl Export for GodotString
[src]
type Hint = StringHint
A type-specific hint type that is valid for the type being exported.
fn export_info(hint: Option<Self::Hint>) -> ExportInfo
[src]
impl From<GodotString> for NodePath
[src]
fn from(s: GodotString) -> NodePath
[src]
impl<S> From<S> for GodotString where
S: AsRef<str>,
[src]
S: AsRef<str>,
fn from(s: S) -> GodotString
[src]
impl FromVariant for GodotString
[src]
fn from_variant(variant: &Variant) -> Result<Self, FromVariantError>
[src]
impl Hash for GodotString
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Index<usize> for GodotString
[src]
The index operator provides a low-level view of characters in Godot's native encoding
that doesn't always correspond to Unicode code points one-to-one. This operation goes
through FFI. For intensive string operations, consider converting to a Rust String
first to avoid this cost.
type Output = GodotChar
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output
[src]
impl Into<GodotString> for NodePath
[src]
fn into(self) -> GodotString
[src]
impl NewRef for GodotString
[src]
fn new_ref(&self) -> GodotString
[src]
impl Ord for GodotString
[src]
fn cmp(&self, other: &GodotString) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<GodotString> for GodotString
[src]
impl PartialOrd<GodotString> for GodotString
[src]
fn partial_cmp(&self, other: &GodotString) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl ToVariant for GodotString
[src]
fn to_variant(&self) -> Variant
[src]
impl ToVariantEq for GodotString
[src]
Auto Trait Implementations
impl RefUnwindSafe for GodotString
[src]
impl Send for GodotString
[src]
impl Sync for GodotString
[src]
impl Unpin for GodotString
[src]
impl UnwindSafe for GodotString
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CallHasher for T where
T: Hash + ?Sized,
[src]
T: Hash + ?Sized,
pub default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64 where
H: Hash + ?Sized,
B: BuildHasher,
[src]
H: Hash + ?Sized,
B: BuildHasher,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> OwnedToVariant for T where
T: ToVariant,
[src]
T: ToVariant,
pub fn owned_to_variant(Self) -> Variant
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,