Enum koto_runtime::prelude::KValue
source · pub enum KValue {
}
Expand description
The core Value type for Koto
Variants§
Null
The default type representing the absence of a value
Bool(bool)
A boolean, can be either true or false
Number(KNumber)
A number, represented as either a signed 64 bit integer or float
Range(KRange)
A range with start/end boundaries
List(KList)
The list type used in Koto
Tuple(KTuple)
The tuple type used in Koto
Map(KMap)
The hash map type used in Koto
Str(KString)
The string type used in Koto
Function(KFunction)
A Koto function
CaptureFunction(Ptr<KCaptureFunction>)
A Koto function with captures
NativeFunction(KNativeFunction)
A function that’s implemented outside of the Koto runtime
Iterator(KIterator)
The iterator type used in Koto
Object(KObject)
An object with behaviour defined via the KotoObject trait
TemporaryTuple(RegisterSlice)
A tuple of values that are packed into a contiguous series of registers
Used as an optimization when multiple values are passed around without being assigned to a single Tuple value.
Note: this is intended for internal use only.
Implementations§
source§impl KValue
impl KValue
sourcepub fn deep_copy(&self) -> Result<KValue>
pub fn deep_copy(&self) -> Result<KValue>
Returns a recursive ‘deep copy’ of a Value
This is used by koto.deep_copy.
sourcepub fn is_callable(&self) -> bool
pub fn is_callable(&self) -> bool
Returns true if the value has function-like callable behaviour
sourcepub fn is_generator(&self) -> bool
pub fn is_generator(&self) -> bool
Returns true if the value is a generator function
sourcepub fn is_hashable(&self) -> bool
pub fn is_hashable(&self) -> bool
Returns true if the value is hashable
Only hashable values are acceptable as map keys.
sourcepub fn is_iterable(&self) -> bool
pub fn is_iterable(&self) -> bool
Returns true if a KIterator can be made from the value
sourcepub fn type_as_string(&self) -> KString
pub fn type_as_string(&self) -> KString
Returns the value’s type as a KString
sourcepub fn display(&self, ctx: &mut DisplayContext<'_>) -> Result<()>
pub fn display(&self, ctx: &mut DisplayContext<'_>) -> Result<()>
Renders the value into the provided display context
Trait Implementations§
source§impl From<IteratorOutput> for KValue
impl From<IteratorOutput> for KValue
source§fn from(output: IteratorOutput) -> Self
fn from(output: IteratorOutput) -> Self
source§impl From<KNativeFunction> for KValue
impl From<KNativeFunction> for KValue
source§fn from(value: KNativeFunction) -> Self
fn from(value: KNativeFunction) -> Self
source§impl From<KValue> for IteratorOutput
impl From<KValue> for IteratorOutput
source§impl<T> From<T> for KValuewhere
T: KotoFunction,
impl<T> From<T> for KValuewhere
T: KotoFunction,
source§impl TryFrom<KIteratorOutput> for KValue
impl TryFrom<KIteratorOutput> for KValue
Auto Trait Implementations§
impl Freeze for KValue
impl !RefUnwindSafe for KValue
impl Send for KValue
impl Sync for KValue
impl Unpin for KValue
impl !UnwindSafe for KValue
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.