Crate tvm_ffi

Source

Re-exports§

Modules§

  • Integers with inline i64 storage and arbitrary-precision arithmetic.
  • In-place mirror of C++ ffi::Optional<T> for non-object-pointer T (include/tvm/ffi/optional.h).
  • Safe access to object reflection metadata.
  • Move-aware object arguments compatible with C++ ffi::RValueRef<T>.
  • Static init blocks: code that runs when the program or library that holds it loads, as a C++ TVM_FFI_STATIC_INIT_BLOCK does. The blocks of a program or library are gathered at link time, wherever in it they are, and a constructor runs them when it loads. Once Python loads a library built on this crate, by any means, it sees what the blocks registered, as it sees the registrations of a C++ library. A block that several libraries of a process have, as each links its own copy of a crate they share, runs once. See static_init_block!.

Macros§

  • Attach a context to a result if it is error
  • Create a new error with file/line info attached
  • Resolves a registered global Function by name and caches it for the lifetime of the process (lock-free after the first lookup). Each call site gets its own cache and the macro evaluates to a &'static Function. Panics — naming the function — if it is not registered.
  • Check the return code of the safe call
  • Define the reference to an object type, as C++ TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE does: def_object_ref!(TypeName, ParentType, ObjectName).
  • Create a new error with file/line info attached
  • Macro gto get the name of the function
  • Macro to implement ArgIntoRef for a list of types
  • Macro to implement IntoArgHolder for a list of types
  • Implement zero-copy conversions from a derived object reference to one of its base object-reference types.
  • Macro to implement TryFrom<AnyView> and TryFrom<Any> for a list of types
  • Macro to implement TryFrom<AnyView> and TryFrom<Any> for generic types like Option<T>

  • Match payloads in Any, AnyView, object references or MutationView.
  • Run code when the program or library that holds it loads, as a C++ TVM_FFI_STATIC_INIT_BLOCK does. The body is the body of a function that returns Result<()>: it registers what the library defines, such as global functions, and stops at its first error, which ? returns. A body whose statements all end in ; returns Ok(()); one that ends in an expression returns it, a Result<()>.
  • Macro to export a typed function as a C symbol that follows the tvm-ffi ABI
  • Macro to export the doc string of a function exported with tvm_ffi_dll_export_typed_func!, as C++ TVM_FFI_DLL_EXPORT_TYPED_FUNC_DOC does

Structs§

Enums§

Type Aliases§

Attribute Macros§

  • Generate source-ordered runtime type dispatch from prefix_* handlers.
  • Define an object type in Rust from its object struct, as Python’s py_class does: the type registers its key with the reflection of every field, so that C++ structural equality and hashing, repr, deep copy and Python see the fields.