Enum koto_runtime::prelude::KValue

source ·
pub enum KValue {
Show 14 variants Null, Bool(bool), Number(KNumber), Range(KRange), List(KList), Tuple(KTuple), Map(KMap), Str(KString), Function(KFunction), CaptureFunction(Ptr<KCaptureFunction>), NativeFunction(KNativeFunction), Iterator(KIterator), Object(KObject), TemporaryTuple(RegisterSlice),
}
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

source

pub fn deep_copy(&self) -> Result<KValue>

Returns a recursive ‘deep copy’ of a Value

This is used by koto.deep_copy.

source

pub fn is_callable(&self) -> bool

Returns true if the value has function-like callable behaviour

source

pub fn is_generator(&self) -> bool

Returns true if the value is a generator function

source

pub fn is_hashable(&self) -> bool

Returns true if the value is hashable

Only hashable values are acceptable as map keys.

source

pub fn is_iterable(&self) -> bool

Returns true if a KIterator can be made from the value

source

pub fn type_as_string(&self) -> KString

Returns the value’s type as a KString

source

pub fn display(&self, ctx: &mut DisplayContext<'_>) -> Result<()>

Renders the value into the provided display context

Trait Implementations§

source§

impl Clone for KValue

source§

fn clone(&self) -> KValue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for KValue

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for KValue

source§

fn default() -> KValue

Returns the “default value” for a type. Read more
source§

impl From<&f32> for KValue

source§

fn from(value: &f32) -> Self

Converts to this type from the input type.
source§

impl From<&f64> for KValue

source§

fn from(value: &f64) -> Self

Converts to this type from the input type.
source§

impl From<&i16> for KValue

source§

fn from(value: &i16) -> Self

Converts to this type from the input type.
source§

impl From<&i32> for KValue

source§

fn from(value: &i32) -> Self

Converts to this type from the input type.
source§

impl From<&i64> for KValue

source§

fn from(value: &i64) -> Self

Converts to this type from the input type.
source§

impl From<&i8> for KValue

source§

fn from(value: &i8) -> Self

Converts to this type from the input type.
source§

impl From<&isize> for KValue

source§

fn from(value: &isize) -> Self

Converts to this type from the input type.
source§

impl From<&str> for KValue

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl From<&u16> for KValue

source§

fn from(value: &u16) -> Self

Converts to this type from the input type.
source§

impl From<&u32> for KValue

source§

fn from(value: &u32) -> Self

Converts to this type from the input type.
source§

impl From<&u64> for KValue

source§

fn from(value: &u64) -> Self

Converts to this type from the input type.
source§

impl From<&u8> for KValue

source§

fn from(value: &u8) -> Self

Converts to this type from the input type.
source§

impl From<&usize> for KValue

source§

fn from(value: &usize) -> Self

Converts to this type from the input type.
source§

impl From<()> for KValue

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<Chunk> for KValue

source§

fn from(chunk: Chunk) -> Self

Converts to this type from the input type.
source§

impl From<File> for KValue

source§

fn from(file: File) -> Self

Converts to this type from the input type.
source§

impl From<IteratorOutput> for KValue

source§

fn from(output: IteratorOutput) -> Self

Converts to this type from the input type.
source§

impl From<KIterator> for KValue

source§

fn from(value: KIterator) -> Self

Converts to this type from the input type.
source§

impl From<KList> for KValue

source§

fn from(value: KList) -> Self

Converts to this type from the input type.
source§

impl From<KMap> for KValue

source§

fn from(value: KMap) -> Self

Converts to this type from the input type.
source§

impl From<KNativeFunction> for KValue

source§

fn from(value: KNativeFunction) -> Self

Converts to this type from the input type.
source§

impl From<KNumber> for KValue

source§

fn from(value: KNumber) -> Self

Converts to this type from the input type.
source§

impl From<KObject> for KValue

source§

fn from(value: KObject) -> Self

Converts to this type from the input type.
source§

impl From<KRange> for KValue

source§

fn from(value: KRange) -> Self

Converts to this type from the input type.
source§

impl From<KString> for KValue

source§

fn from(value: KString) -> Self

Converts to this type from the input type.
source§

impl From<KTuple> for KValue

source§

fn from(value: KTuple) -> Self

Converts to this type from the input type.
source§

impl From<KValue> for IteratorOutput

source§

fn from(value: KValue) -> Self

Converts to this type from the input type.
source§

impl From<String> for KValue

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl<T> From<T> for KValue
where T: KotoFunction,

source§

fn from(value: T) -> Self

Converts to this type from the input type.
source§

impl From<bool> for KValue

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for KValue

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for KValue

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl From<i16> for KValue

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for KValue

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for KValue

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for KValue

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl From<isize> for KValue

source§

fn from(value: isize) -> Self

Converts to this type from the input type.
source§

impl From<u16> for KValue

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for KValue

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for KValue

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for KValue

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for KValue

source§

fn from(value: usize) -> Self

Converts to this type from the input type.
source§

impl TryFrom<KIteratorOutput> for KValue

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(iterator_output: KIteratorOutput) -> StdResult<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<KValue> for ValueKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: KValue) -> Result<Self, Self::Error>

Performs the conversion.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

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.
source§

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.
source§

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.
source§

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.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.