Struct sciter::value::IsolatedValue
[−]
[src]
pub struct IsolatedValue(_);
Used to pass values between threads.
sciter::Value can not be transferred across thread boundaries,
because essentially it is the reference to a certain resource of the single-threaded script VM.
Value.isolate() is used to convert T_OBJECT value type
to plain T_MAP or T_ARRAY JSON types.
Isolated value does not contain references to the DOM anymore and therefore is not required
to be accessed from GUI thread only.
That said, you can move such values between threads.
Example:
let mut v = sciter::Value::map(); v.set_item("seven", 7); let charon = v.isolate(); let tid = std::thread::spawn(move || { let mut v = charon; assert_eq!(v.len(), 1); }); tid.join().unwrap();
Methods from Deref<Target = Value>
pub fn get_type(&self) -> VALUE_TYPE[src]
Get the inner type of the value.
pub fn full_type(&self) -> (VALUE_TYPE, UINT)[src]
Get the inner type and its subtype (e.g. units) of the value.
pub fn clear(&mut self) -> &mut Value[src]
Clear the value. It deallocates all assosiated structures that are not used anywhere else.
pub fn len(&self) -> usize[src]
Return the number of items in the T_ARRAY, T_MAP, T_FUNCTION and T_OBJECT value types.
pub fn push<T: Into<Value>>(&mut self, src: T)[src]
Append another value to the end of T_ARRAY value.
pub fn set<T: Into<Value>>(&mut self, index: usize, src: T)[src]
Insert or set value at the given index of T_ARRAY, T_MAP, T_FUNCTION and T_OBJECT value.
pub fn get(&self, index: usize) -> Value[src]
Retreive value of sub-element at index.
T_ARRAY- nth element of the array;T_MAP- value of the nth key/value pair in the map;T_FUNCTION- value of the nth argument of the function.
pub fn set_item<TKey: Into<Value>, TValue: Into<Value>>(
&mut self,
key: TKey,
value: TValue
)[src]
&mut self,
key: TKey,
value: TValue
)
Insert or set value of the sub-element by key.
T_MAP- sets named value in the map;T_OBJECT- sets value of property of the object;T_FUNCTION- sets named argument of the function;- otherwise it converts self to the map type and adds the key/value to it.
pub fn get_item<T: Into<Value>>(&self, key: T) -> Value[src]
Retrieve the value of a sub-element by key.
pub fn key_at(&self, index: usize) -> Value[src]
Retrieve the key of a sub-element by index.
ⓘImportant traits for KeyIterator<'a>pub fn keys(&self) -> KeyIterator[src]
An iterator visiting all keys of key/value pairs in the map.
T_MAP- keys of key/value pairs in the map;T_OBJECT- names of key/value properties in the object;T_FUNCTION- names of arguments of the function (if any).
ⓘImportant traits for SeqIterator<'a>pub fn values(&self) -> SeqIterator[src]
An iterator visiting all values in arbitrary order.
T_ARRAY- elements of the array;T_MAP- values of key/value pairs in the map;T_OBJECT- values of key/value properties in the object;T_FUNCTION- values of arguments of the function.
pub fn items(&self) -> Vec<(Value, Value)>[src]
An iterator visiting all key-value pairs in arbitrary order.
The iterator element type is (Value, Value).
The Value must has a key-value type (map, object, function).
pub fn to_int(&self) -> Option<i32>[src]
Value to integer.
pub fn to_bool(&self) -> Option<bool>[src]
Value to bool.
pub fn to_float(&self) -> Option<f64>[src]
Value to float.
pub fn to_color(&self) -> Option<u32>[src]
Value to color.
pub fn to_duration(&self) -> Option<f64>[src]
Value to duration.
pub fn to_angle(&self) -> Option<f64>[src]
Value to angle.
pub fn as_string(&self) -> Option<String>[src]
Value as string for T_STRING type.
pub fn as_bytes(&self) -> Option<&[u8]>[src]
Value as a byte slice for T_BYTES type.
pub fn to_bytes(&self) -> Option<Vec<u8>>[src]
Value to byte vector for T_BYTES type.
pub fn call(
&self,
this: Option<Value>,
args: &[Value],
name: Option<&str>
) -> Result<Value, VALUE_RESULT>[src]
&self,
this: Option<Value>,
args: &[Value],
name: Option<&str>
) -> Result<Value, VALUE_RESULT>
Function invocation for T_OBJECT with UT_OBJECT_FUNCTION value type.
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).
The name here is an url or a name of the script - used for error reporting in script.
You can use the make_args!(args...) macro which helps you
to construct script arguments from Rust types.
pub fn is_empty(&self) -> bool[src]
Returns true is self is undefined or has zero elements.
pub fn is_undefined(&self) -> bool[src]
pub fn is_null(&self) -> bool[src]
pub fn is_bool(&self) -> bool[src]
pub fn is_int(&self) -> bool[src]
pub fn is_float(&self) -> bool[src]
pub fn is_bytes(&self) -> bool[src]
pub fn is_string(&self) -> bool[src]
pub fn is_symbol(&self) -> bool[src]
pub fn is_error_string(&self) -> bool[src]
pub fn is_date(&self) -> bool[src]
pub fn is_currency(&self) -> bool[src]
pub fn is_color(&self) -> bool[src]
pub fn is_duration(&self) -> bool[src]
pub fn is_angle(&self) -> bool[src]
pub fn is_map(&self) -> bool[src]
pub fn is_array(&self) -> bool[src]
pub fn is_function(&self) -> bool[src]
pub fn is_native_function(&self) -> bool[src]
pub fn is_object(&self) -> bool[src]
pub fn is_dom_element(&self) -> bool[src]
Trait Implementations
impl Debug for IsolatedValue[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl Send for IsolatedValue[src]
Isolated value can be moved to another thread.
impl Deref for IsolatedValue[src]
Dereference to &Value.
type Target = Value
The resulting type after dereferencing.
fn deref(&self) -> &Value[src]
Dereferences the value.
impl DerefMut for IsolatedValue[src]
Dereference to &mut Value.