pub enum KclValue {
Show 18 variants
Uuid {
value: Uuid,
meta: Vec<Metadata>,
},
Bool {
value: bool,
meta: Vec<Metadata>,
},
Number {
value: f64,
meta: Vec<Metadata>,
},
Int {
value: i64,
meta: Vec<Metadata>,
},
String {
value: String,
meta: Vec<Metadata>,
},
Array {
value: Vec<KclValue>,
meta: Vec<Metadata>,
},
Object {
value: HashMap<String, KclValue>,
meta: Vec<Metadata>,
},
TagIdentifier(Box<TagIdentifier>),
TagDeclarator(Box<Node<TagDeclarator>>),
Plane(Box<Plane>),
Face(Box<Face>),
Sketch {
value: Box<Sketch>,
},
Sketches {
value: Vec<Box<Sketch>>,
},
Solid(Box<Solid>),
Solids {
value: Vec<Box<Solid>>,
},
ImportedGeometry(ImportedGeometry),
Function {
func: Option<fn(s: Vec<Arg>, memory: ProgramMemory, expression: Box<Node<FunctionExpression>>, metadata: Vec<Metadata>, exec_state: &ExecState, ctx: ExecutorContext) -> Pin<Box<dyn Future<Output = Result<Option<KclValue>, KclError>> + Send>>>,
expression: Box<Node<FunctionExpression>>,
memory: Box<ProgramMemory>,
meta: Vec<Metadata>,
},
KclNone {
value: KclNone,
meta: Vec<Metadata>,
},
}
Expand description
Any KCL value.
Variants§
Uuid
Bool
Number
Int
String
Array
Object
TagIdentifier(Box<TagIdentifier>)
TagDeclarator(Box<Node<TagDeclarator>>)
Plane(Box<Plane>)
Face(Box<Face>)
Sketch
Sketches
Solid(Box<Solid>)
Solids
ImportedGeometry(ImportedGeometry)
Function
Fields
§
func: Option<fn(s: Vec<Arg>, memory: ProgramMemory, expression: Box<Node<FunctionExpression>>, metadata: Vec<Metadata>, exec_state: &ExecState, ctx: ExecutorContext) -> Pin<Box<dyn Future<Output = Result<Option<KclValue>, KclError>> + Send>>>
Adam Chalmers speculation: Reference to a KCL stdlib function (written in Rust). Some if the KCL value is an alias of a stdlib function, None if it’s a KCL function written/declared in KCL.
§
memory: Box<ProgramMemory>
KclNone
Implementations§
Source§impl KclValue
impl KclValue
Sourcepub const fn from_number(f: f64, meta: Vec<Metadata>) -> Self
pub const fn from_number(f: f64, meta: Vec<Metadata>) -> Self
Put the number into a KCL value.
Sourcepub fn from_point2d(p: [f64; 2], meta: Vec<Metadata>) -> Self
pub fn from_point2d(p: [f64; 2], meta: Vec<Metadata>) -> Self
Put the point into a KCL value.
pub fn as_int(&self) -> Option<i64>
pub fn as_object(&self) -> Option<&HashMap<String, KclValue>>
pub fn into_object(self) -> Option<HashMap<String, KclValue>>
pub fn as_str(&self) -> Option<&str>
pub fn as_array(&self) -> Option<&[KclValue]>
pub fn as_point2d(&self) -> Option<[f64; 2]>
pub fn as_uuid(&self) -> Option<Uuid>
pub fn as_plane(&self) -> Option<&Plane>
pub fn as_solid(&self) -> Option<&Solid>
pub fn as_f64(&self) -> Option<f64>
pub fn as_bool(&self) -> Option<bool>
Sourcepub fn get_u32(&self, source_ranges: Vec<SourceRange>) -> Result<u32, KclError>
pub fn get_u32(&self, source_ranges: Vec<SourceRange>) -> Result<u32, KclError>
If this value fits in a u32, return it.
Sourcepub fn get_function(&self) -> Option<FnAsArg<'_>>
pub fn get_function(&self) -> Option<FnAsArg<'_>>
If this value is of type function, return it.
Sourcepub fn get_tag_identifier(&self) -> Result<TagIdentifier, KclError>
pub fn get_tag_identifier(&self) -> Result<TagIdentifier, KclError>
Get a tag identifier from a memory item.
Sourcepub fn get_tag_declarator(&self) -> Result<Node<TagDeclarator>, KclError>
pub fn get_tag_declarator(&self) -> Result<Node<TagDeclarator>, KclError>
Get a tag declarator from a memory item.
Sourcepub fn get_tag_declarator_opt(
&self,
) -> Result<Option<Node<TagDeclarator>>, KclError>
pub fn get_tag_declarator_opt( &self, ) -> Result<Option<Node<TagDeclarator>>, KclError>
Get an optional tag from a memory item.
Sourcepub async fn call_fn(
&self,
args: Vec<Arg>,
exec_state: &mut ExecState,
ctx: ExecutorContext,
) -> Result<Option<KclValue>, KclError>
pub async fn call_fn( &self, args: Vec<Arg>, exec_state: &mut ExecState, ctx: ExecutorContext, ) -> Result<Option<KclValue>, KclError>
If this memory item is a function, call it with the given arguments, return its val as Ok. If it’s not a function, return Err.
Sourcepub async fn call_fn_kw(
&self,
args: Args,
exec_state: &mut ExecState,
ctx: ExecutorContext,
callsite: SourceRange,
) -> Result<Option<KclValue>, KclError>
pub async fn call_fn_kw( &self, args: Args, exec_state: &mut ExecState, ctx: ExecutorContext, callsite: SourceRange, ) -> Result<Option<KclValue>, KclError>
If this is a function, call it by applying keyword arguments. If it’s not a function, returns an error.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KclValue
impl<'de> Deserialize<'de> for KclValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for KclValue
impl JsonSchema for KclValue
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moreSource§impl TS for KclValue
impl TS for KclValue
Source§const DOCS: Option<&'static str> = _
const DOCS: Option<&'static str> = _
JSDoc comment to describe this type in TypeScript - when
TS
is derived, docs are
automatically read from your doc comments or #[doc = ".."]
attributesSource§type WithoutGenerics = KclValue
type WithoutGenerics = KclValue
If this type does not have generic parameters, then
WithoutGenerics
should just be Self
.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy
or ()
.
The only requirement for these dummy types is that EXPORT_TO
must be None
. Read moreSource§fn decl_concrete() -> String
fn decl_concrete() -> String
Declaration of this type using the supplied generic arguments.
The resulting TypeScript definition will not be generic. For that, see
TS::decl()
.
If this type is not generic, then this function is equivalent to TS::decl()
.Source§fn decl() -> String
fn decl() -> String
Declaration of this type, e.g.
type User = { user_id: number, ... }
.
This function will panic if the type has no declaration. Read moreSource§fn inline() -> String
fn inline() -> String
Formats this types definition in TypeScript, e.g
{ user_id: number }
.
This function will panic if the type cannot be inlined.Source§fn inline_flattened() -> String
fn inline_flattened() -> String
Flatten a type declaration.
This function will panic if the type cannot be flattened.
This function will panic if the type cannot be flattened.
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Iterates over all type parameters of this type.
Source§fn output_path() -> Option<&'static Path>
fn output_path() -> Option<&'static Path>
Returns the output path to where
The returned path does not include the base directory from
T
should be exported.The returned path does not include the base directory from
TS_RS_EXPORT_DIR
. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Iterates over all dependency of this type.
Source§fn dependencies() -> Vec<Dependency>where
Self: 'static,
fn dependencies() -> Vec<Dependency>where
Self: 'static,
Resolves all dependencies of this type recursively.
Source§fn export() -> Result<(), ExportError>where
Self: 'static,
fn export() -> Result<(), ExportError>where
Self: 'static,
Manually export this type to the filesystem.
To export this type together with all of its dependencies, use
TS::export_all
. Read moreSource§fn export_all() -> Result<(), ExportError>where
Self: 'static,
fn export_all() -> Result<(), ExportError>where
Self: 'static,
Manually export this type to the filesystem, together with all of its dependencies.
To export only this type, without its dependencies, use
To export only this type, without its dependencies, use
TS::export
. Read moreSource§fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
Manually export this type into the given directory, together with all of its dependencies.
To export only this type, without its dependencies, use
To export only this type, without its dependencies, use
TS::export
. Read moreSource§fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
impl StructuralPartialEq for KclValue
Auto Trait Implementations§
impl Freeze for KclValue
impl RefUnwindSafe for KclValue
impl Send for KclValue
impl Sync for KclValue
impl Unpin for KclValue
impl UnwindSafe for KclValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.