std.reflect
API summary (generated from the Beans source by npm run coverage): 7 package functions · 18 types · 94 instance methods · 40 enum variants.
std.reflect provides safe runtime metadata and checked dynamic actions. See
the reflection guide for examples, ownership rules, and
limits.
import std.reflectRegistry functions
Section titled “Registry functions”pub fn value<T>(move item: T) -> Valuepub fn types() -> List<Type>pub fn find_type(qualified_name: string) -> Option<Type>pub fn functions() -> List<Function>pub fn find_function(qualified_name: string) -> Option<Function>pub fn annotation_types() -> List<AnnotationType>pub fn find_annotation_type(qualified_name: string) -> Option<AnnotationType>Use the contextual type_of(T) builtin for a type known at compile time.
Type and member descriptors
Section titled “Type and member descriptors”pub class Typepub fn qualified_name() -> stringpub fn name() -> stringpub fn kind() -> Kindpub fn type_arguments() -> List<Type>pub fn base_type() -> Option<Type>pub fn interfaces() -> List<Type>pub fn is_assignable_from(other: Type) -> boolpub fn declared_fields() -> List<Field>pub fn fields() -> List<Field>pub fn field(name: string) -> Option<Field>pub fn declared_methods() -> List<Method>pub fn methods() -> List<Method>pub fn method(name: string) -> Option<Method>pub fn initializer() -> Option<Initializer>pub fn variants() -> List<Variant>pub fn annotations() -> List<Annotation>pub fn variant(name: string) -> Option<Variant>pub class Fieldpub fn name() -> stringpub fn type() -> Typepub fn declaring_type() -> Typepub fn is_public() -> boolpub fn has_default() -> boolpub fn get(receiver: Value) -> Result<Value, ReflectError>pub fn set(receiver: Value, move value: Value) -> Result<bool, ReflectError>pub fn annotations() -> List<Annotation>pub class Methodpub fn name() -> stringpub fn declaring_type() -> Typepub fn result_type() -> Typepub fn is_public() -> boolpub fn is_static() -> boolpub fn is_async() -> boolpub fn is_generic() -> boolpub fn parameters() -> List<Parameter>pub fn call(receiver: Value, move arguments: List<Value>) -> Result<Value, ReflectError>pub fn call_static(move arguments: List<Value>) -> Result<Value, ReflectError>pub fn annotations() -> List<Annotation>pub class Initializerpub fn declaring_type() -> Typepub fn is_public() -> boolpub fn is_async() -> boolpub fn is_generic() -> boolpub fn parameters() -> List<Parameter>pub fn annotations() -> List<Annotation>pub fn call(move arguments: List<Value>) -> Result<Value, ReflectError>pub class Variantpub fn name() -> stringpub fn declaring_type() -> Typepub fn parameters() -> List<Parameter>pub fn annotations() -> List<Annotation>pub fn make(move arguments: List<Value>) -> Result<Value, ReflectError>pub class Functionpub fn qualified_name() -> stringpub fn name() -> stringpub fn result_type() -> Typepub fn is_public() -> boolpub fn is_async() -> boolpub fn is_generic() -> boolpub fn parameters() -> List<Parameter>pub fn call(move arguments: List<Value>) -> Result<Value, ReflectError>pub fn annotations() -> List<Annotation>pub class Parameterpub fn name() -> stringpub fn type() -> Typepub fn passing() -> Passingpub fn annotations() -> List<Annotation>Dynamic values
Section titled “Dynamic values”pub class Valuepub fn type() -> Typepub fn copy() -> Valuepub fn is_type(wanted: Type) -> boolvalue(item) transfers its argument into the box. A checked as? copies a
copyable payload. Write move boxed as? T to take a move-only payload.
Annotation descriptors
Section titled “Annotation descriptors”pub class AnnotationTypepub fn qualified_name() -> stringpub fn name() -> stringpub fn is_public() -> boolpub fn is_repeatable() -> boolpub fn retention() -> stringpub fn targets() -> List<string>pub fn fields() -> List<AnnotationField>pub fn field(name: string) -> Option<AnnotationField>pub fn annotations() -> List<Annotation>pub class AnnotationFieldpub fn name() -> stringpub fn type() -> Typepub fn has_default() -> boolpub fn default_value() -> Option<AnnotationValue>pub class Annotationpub fn qualified_name() -> stringpub fn name() -> stringpub fn type() -> AnnotationTypepub fn arguments() -> List<AnnotationArgument>pub fn argument(name: string) -> Option<AnnotationArgument>pub class AnnotationArgumentpub fn name() -> stringpub fn type() -> Typepub fn value() -> AnnotationValuepub class AnnotationValuepub fn kind() -> AnnotationValueKindpub fn type() -> Typepub fn text() -> stringpub fn as_bool() -> Option<bool>pub fn as_int() -> Option<int>pub fn as_string() -> Option<string>pub fn items() -> List<AnnotationValue>Errors and enums
Section titled “Errors and enums”pub class ReflectErrorpub fn kind() -> ErrorKindpub fn message() -> stringKind has unit, boolean, signed_integer, unsigned_integer, floating,
decimal, string, class_type, interface_type, struct_type,
union_type, enum_type, list, map, option, result, fixed_array,
slice, raw_pointer, function_type, and other.
Passing has borrowed, taken, and mutable.
AnnotationValueKind has boolean, signed_integer, unsigned_integer,
floating, decimal, string, enum_value, list, and other.
ErrorKind has missing, inaccessible, receiver_type, value_type,
unsupported, argument_count, and failed.