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 নিরাপদ runtime metadata আর checked dynamic action দেয়। উদাহরণ,
ownership-এর নিয়ম, আর সীমাবদ্ধতা জানতে দেখুন
reflection guide।
import std.reflectRegistry function
“Registry function” সেকশন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>কম্পাইল টাইমে জানা কোনো type-এর জন্য contextual type_of(T) builtin ব্যবহার করুন।
Type আর member descriptor
“Type আর member descriptor” সেকশন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 value
“Dynamic value” সেকশনpub class Valuepub fn type() -> Typepub fn copy() -> Valuepub fn is_type(wanted: Type) -> boolvalue(item) তার argument-টাকে box-এর ভেতর সরিয়ে নেয়। একটা checked as?
copyable payload কপি করে। move-only payload নিতে হলে লিখুন move boxed as? T।
Annotation descriptor
“Annotation descriptor” সেকশন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>Error আর enum
“Error আর enum” সেকশনpub class ReflectErrorpub fn kind() -> ErrorKindpub fn message() -> stringKind-এ আছে 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, আর other।
Passing-এ আছে borrowed, taken, আর mutable।
AnnotationValueKind-এ আছে boolean, signed_integer, unsigned_integer,
floating, decimal, string, enum_value, list, আর other।
ErrorKind-এ আছে missing, inaccessible, receiver_type, value_type,
unsupported, argument_count, আর failed।