Struct soroban_sdk::String
source · pub struct String { /* private fields */ }
Expand description
String is a contiguous growable array type containing u8
s.
The array is stored in the Host and available to the Guest through the functions defined on String.
String values can be stored as Storage, or in other types like Vec, Map, etc.
Examples
String values can be created from slices:
use soroban_sdk::{String, Env};
let env = Env::default();
let msg = "a message";
let s = String::from_str(&env, msg);
let mut out = [0u8; 9];
s.copy_into_slice(&mut out);
assert_eq!(msg.as_bytes(), out)
Implementations§
source§impl String
impl String
pub fn env(&self) -> &Env
pub fn as_val(&self) -> &Val
pub fn to_val(&self) -> Val
pub fn as_object(&self) -> &StringObject
pub fn to_object(&self) -> StringObject
pub fn from_bytes(env: &Env, b: &[u8]) -> String
pub fn from_str(env: &Env, s: &str) -> String
pub fn len(&self) -> u32
sourcepub fn copy_into_slice(&self, slice: &mut [u8])
pub fn copy_into_slice(&self, slice: &mut [u8])
Trait Implementations§
source§impl Ord for String
impl Ord for String
source§impl PartialEq for String
impl PartialEq for String
source§impl PartialOrd for String
impl PartialOrd for String
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SorobanArbitrary for String
Available on crate feature testutils
only.
impl SorobanArbitrary for String
Available on crate feature
testutils
only.§type Prototype = ArbitraryString
type Prototype = ArbitraryString
A type that implements
Arbitrary
and can be converted to this
SorobanArbitrary
type.source§impl TryFrom<&String> for ScVal
impl TryFrom<&String> for ScVal
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<String> for ScVal
impl TryFrom<String> for ScVal
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFromVal<Env, &str> for String
impl TryFromVal<Env, &str> for String
type Error = ConversionError
fn try_from_val(env: &Env, v: &&str) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, ScVal> for String
impl TryFromVal<Env, ScVal> for String
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, String> for String
impl TryFromVal<Env, String> for String
type Error = ConversionError
fn try_from_val(_env: &Env, v: &String) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, String> for Val
impl TryFromVal<Env, String> for Val
type Error = ConversionError
fn try_from_val(_env: &Env, v: &String) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, StringObject> for String
impl TryFromVal<Env, StringObject> for String
type Error = Infallible
fn try_from_val(env: &Env, val: &StringObject) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, Val> for String
impl TryFromVal<Env, Val> for String
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, Self::Error>
impl Eq for String
Auto Trait Implementations§
impl !RefUnwindSafe for String
impl !Send for String
impl !Sync for String
impl Unpin for String
impl !UnwindSafe for String
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
§impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W) ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X) ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.