Enum kcl_lib::executor::MemoryItem
source · pub enum MemoryItem {
UserVal(UserVal),
TagIdentifier(Box<TagIdentifier>),
TagDeclarator(Box<TagDeclarator>),
Plane(Box<Plane>),
Face(Box<Face>),
SketchGroup(Box<SketchGroup>),
SketchGroups {
value: Vec<Box<SketchGroup>>,
},
ExtrudeGroup(Box<ExtrudeGroup>),
ExtrudeGroups {
value: Vec<Box<ExtrudeGroup>>,
},
ImportedGeometry(ImportedGeometry),
Function {
func: Option<MemoryFunction>,
expression: Box<FunctionExpression>,
memory: Box<ProgramMemory>,
meta: Vec<Metadata>,
},
}
Expand description
A memory item.
Variants§
UserVal(UserVal)
TagIdentifier(Box<TagIdentifier>)
TagDeclarator(Box<TagDeclarator>)
Plane(Box<Plane>)
Face(Box<Face>)
SketchGroup(Box<SketchGroup>)
SketchGroups
Fields
§
value: Vec<Box<SketchGroup>>
ExtrudeGroup(Box<ExtrudeGroup>)
ExtrudeGroups
Fields
§
value: Vec<Box<ExtrudeGroup>>
ImportedGeometry(ImportedGeometry)
Function
Implementations§
source§impl MemoryItem
impl MemoryItem
pub fn get_sketch_group_set(&self) -> Result<SketchGroupSet>
pub fn get_extrude_group_set(&self) -> Result<ExtrudeGroupSet>
source§impl MemoryItem
impl MemoryItem
pub fn get_json_value(&self) -> Result<Value, KclError>
sourcepub fn get_json<T: DeserializeOwned>(&self) -> Result<T, KclError>
pub fn get_json<T: DeserializeOwned>(&self) -> Result<T, KclError>
Get a JSON value and deserialize it into some concrete type.
sourcepub fn get_json_opt<T: DeserializeOwned>(&self) -> Result<Option<T>, KclError>
pub fn get_json_opt<T: DeserializeOwned>(&self) -> Result<Option<T>, KclError>
Get a JSON value and deserialize it into some concrete type. If it’s a KCL None, return None. Otherwise return Some.
pub fn as_user_val(&self) -> Option<&UserVal>
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 is of type 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<TagDeclarator, KclError>
pub fn get_tag_declarator(&self) -> Result<TagDeclarator, KclError>
Get a tag declarator from a memory item.
sourcepub fn get_tag_declarator_opt(&self) -> Result<Option<TagDeclarator>, KclError>
pub fn get_tag_declarator_opt(&self) -> Result<Option<TagDeclarator>, KclError>
Get an optional tag from a memory item.
sourcepub async fn call_fn(
&self,
args: Vec<MemoryItem>,
ctx: ExecutorContext,
) -> Result<Option<ProgramReturn>, KclError>
pub async fn call_fn( &self, args: Vec<MemoryItem>, ctx: ExecutorContext, ) -> Result<Option<ProgramReturn>, 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.
Trait Implementations§
source§impl Clone for MemoryItem
impl Clone for MemoryItem
source§fn clone(&self) -> MemoryItem
fn clone(&self) -> MemoryItem
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MemoryItem
impl Debug for MemoryItem
source§impl<'de> Deserialize<'de> for MemoryItem
impl<'de> Deserialize<'de> for MemoryItem
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 From<&Box<TagDeclarator>> for MemoryItem
impl From<&Box<TagDeclarator>> for MemoryItem
source§fn from(tag: &Box<TagDeclarator>) -> Self
fn from(tag: &Box<TagDeclarator>) -> Self
Converts to this type from the input type.
source§impl From<&KclNone> for MemoryItem
impl From<&KclNone> for MemoryItem
source§impl From<&TagDeclarator> for MemoryItem
impl From<&TagDeclarator> for MemoryItem
source§fn from(tag: &TagDeclarator) -> Self
fn from(tag: &TagDeclarator) -> Self
Converts to this type from the input type.
source§impl From<ExtrudeGroupSet> for MemoryItem
impl From<ExtrudeGroupSet> for MemoryItem
source§fn from(eg: ExtrudeGroupSet) -> Self
fn from(eg: ExtrudeGroupSet) -> Self
Converts to this type from the input type.
source§impl From<Literal> for MemoryItem
impl From<Literal> for MemoryItem
source§impl From<MemoryItem> for Vec<SourceRange>
impl From<MemoryItem> for Vec<SourceRange>
source§fn from(item: MemoryItem) -> Self
fn from(item: MemoryItem) -> Self
Converts to this type from the input type.
source§impl From<SketchGroupSet> for MemoryItem
impl From<SketchGroupSet> for MemoryItem
source§fn from(sg: SketchGroupSet) -> Self
fn from(sg: SketchGroupSet) -> Self
Converts to this type from the input type.
source§impl From<Vec<Box<ExtrudeGroup>>> for MemoryItem
impl From<Vec<Box<ExtrudeGroup>>> for MemoryItem
source§impl From<Vec<Box<SketchGroup>>> for MemoryItem
impl From<Vec<Box<SketchGroup>>> for MemoryItem
source§impl JsonSchema for MemoryItem
impl JsonSchema for MemoryItem
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 PartialEq for MemoryItem
impl PartialEq for MemoryItem
source§fn eq(&self, other: &MemoryItem) -> bool
fn eq(&self, other: &MemoryItem) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for MemoryItem
impl Serialize for MemoryItem
source§impl TS for MemoryItem
impl TS for MemoryItem
§type WithoutGenerics = MemoryItem
type WithoutGenerics = MemoryItem
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§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§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 MemoryItem
Auto Trait Implementations§
impl Freeze for MemoryItem
impl RefUnwindSafe for MemoryItem
impl Send for MemoryItem
impl Sync for MemoryItem
impl Unpin for MemoryItem
impl UnwindSafe for MemoryItem
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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> 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.