Struct sciter::value::Value
[−]
[src]
pub struct Value { /* fields omitted */ }
sciter::value wrapper. See the module-level documentation.
Methods
impl Value
[src]
fn new() -> Value
Return a new sciter value object (undefined).
fn array(length: usize) -> Value
Make explicit array value with given length.
fn map() -> Value
Make explicit map value.
fn null() -> Value
Make explicit json null value.
fn symbol(val: &str) -> Value
Make sciter symbol value.
fn error(val: &str) -> Value
Make sciter error value.
fn parse(val: &str) -> Result<Value, u32>
Parse json string into value.
fn parse_as(val: &str, how: VALUE_STRING_CVT_TYPE) -> Result<Value, u32>
Parse json string into value.
fn from_str(val: &str) -> Result<Self, VALUE_RESULT>
Parse json string into value.
Note that Value::from_str()
parses a json string to value object and returns a Result<Value>
unlike Value::from()
, which returns just string object only.
fn get_type(&self) -> VALUE_TYPE
Get inner value type.
fn full_type(&self) -> (VALUE_TYPE, UINT)
Get inner value type and its subtype (e.g. units).
fn isolate(&mut self)
Convert T_OBJECT value type to JSON T_MAP or T_ARRAY.
fn clear(&mut self) -> &mut Value
Clear the VALUE and deallocates all assosiated structures that are not used anywhere else.
fn len(&self) -> usize
Return the number of items in the T_ARRAY, T_MAP, T_FUNCTION and T_OBJECT sciter::value.
fn push(&mut self, src: Value)
Append value to the end of T_ARRAY sciter::value.
fn set(&mut self, index: usize, src: Value)
Insert or set value at given index
of T_ARRAY, T_MAP, T_FUNCTION and T_OBJECT sciter::value.
fn get(&self, index: usize) -> Value
Retreive value of sub-element at index
- T_ARRAY - nth element of the array;
- T_MAP - value of nth key/value pair in the map;
- T_FUNCTION - value of nth argument of the function.
fn set_item(&mut self, key: Value, value: Value)
Insert or set value of sub-element by key.
- if it is a map - sets named value in the map;
- if it is a function - sets named argument of the function;
- if it is a object - sets value of property of the object;
- otherwise it converts this to map and adds key/v to it.
fn get_item(&self, key: Value) -> Value
Retrieve value of sub-element by key.
fn to_int(&self) -> Option<i32>
Value to integer.
fn to_bool(&self) -> Option<bool>
Value to bool.
fn to_float(&self) -> Option<f64>
Value to float.
fn as_string(&self) -> Option<String>
Value as string for T_STRING type.
fn into_string(&mut self) -> String
Value to json string (converted in-place). Subject to change.
fn as_bytes(&self) -> Option<&[u8]>
Value as byte slice for T_BYTES type.
fn to_bytes(&self) -> Option<Vec<u8>>
Value to byte vector for T_BYTES type.
fn call(&self,
this: Option<Value>,
args: &[Value],
name: Option<&str>)
-> Result<Value, VALUE_RESULT>
this: Option<Value>,
args: &[Value],
name: Option<&str>)
-> Result<Value, VALUE_RESULT>
Function invocation for T_OBJECT/UT_OBJECT_FUNCTION.
Calls the tiscript function or method holded at Value
with context of this
object
that will be known as this inside that function (it is optional for global functions).
name
here is an url or name of the script - used for error reporting in the script.
You can use the make_args!(a,b,c)
macro which help you construct script arguments from Rust types.
fn is_undefined(&self) -> bool
fn is_null(&self) -> bool
fn is_bool(&self) -> bool
fn is_int(&self) -> bool
fn is_float(&self) -> bool
fn is_bytes(&self) -> bool
fn is_string(&self) -> bool
fn is_symbol(&self) -> bool
fn is_error_string(&self) -> bool
fn is_date(&self) -> bool
fn is_currency(&self) -> bool
fn is_map(&self) -> bool
fn is_array(&self) -> bool
fn is_function(&self) -> bool
fn is_native_function(&self) -> bool
fn is_object(&self) -> bool
fn is_dom_element(&self) -> bool
Trait Implementations
impl Display for Value
[src]
Print Value
as json string
impl Debug for Value
[src]
Print Value
as json string with explicit type showed.
impl Drop for Value
[src]
Destroy pointed value.
impl Default for Value
[src]
Return default value (undefined).
impl Clone for Value
[src]
Copies value.
All allocated objects are reference counted so copying is just a matter of increasing reference counts.
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Value
[src]
Compare two values.
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Index<usize> for Value
[src]
Get item by index for array type.
type Output = Value
The returned type after indexing
fn index<'a>(&'a self, index: usize) -> &'a Self::Output
The method for the indexing (container[index]
) operation
impl Index<Value> for Value
[src]
Get item by key for map type.
type Output = Value
The returned type after indexing
fn index<'a>(&'a self, key: Value) -> &'a Self::Output
The method for the indexing (container[index]
) operation
impl From<i32> for Value
[src]
Value from integer.
impl From<f64> for Value
[src]
Value from float.
impl From<bool> for Value
[src]
Value from bool.
impl<'a> From<&'a str> for Value
[src]
Value from string.
impl From<String> for Value
[src]
Value from string.
impl FromStr for Value
[src]
Value from json string.
type Err = VALUE_RESULT
The associated error which can be returned from parsing.
fn from_str(val: &str) -> Result<Self, Self::Err>
Parses a string s
to return a value of this type. Read more
impl<'a> From<&'a [u8]> for Value
[src]
Value from binary array (sequence of bytes).
impl FromIterator<i32> for Value
[src]
Value from sequence of i32
.
fn from_iter<I: IntoIterator<Item=i32>>(iterator: I) -> Self
Creates a value from an iterator. Read more
impl FromIterator<f64> for Value
[src]
Value from sequence of f64
.
fn from_iter<I: IntoIterator<Item=f64>>(iterator: I) -> Self
Creates a value from an iterator. Read more
impl<'a> FromIterator<&'a str> for Value
[src]
Value from sequence of &str
.
fn from_iter<I: IntoIterator<Item=&'a str>>(iterator: I) -> Self
Creates a value from an iterator. Read more
impl FromIterator<String> for Value
[src]
Value from sequence of String
.
fn from_iter<I: IntoIterator<Item=String>>(iterator: I) -> Self
Creates a value from an iterator. Read more
impl<F> From<F> for Value where F: Fn(&[Value]) -> Value
[src]
Value from function.