Hyperon C
Loading...
Searching...
No Matches
module_loader_t Struct Reference

A C representation of the Rust [ModuleLoader] interface. User can provide [ModuleLoader] methods implemented in C. More...

#include <hyperon.h>

Public Attributes

intptr_t(* load )(const void *payload, struct run_context_t *context, struct write_t err)
 A function to load the module my making MeTTa API calls.
intptr_t(* load_tokens )(const void *payload, struct metta_mod_ref_t target, struct metta_t metta, struct write_t err)
 Loads module's tokens into target module. This method is used for both initial token loading and exporting module's tokens into importing module.
void(* to_string )(const void *payload, struct write_t text)
 Prints module loader content as a string, used for implementing [std::fmt::Debug].
void(* free )(void *payload)
 Frees module loader and all associated memory.

Detailed Description

A C representation of the Rust [ModuleLoader] interface. User can provide [ModuleLoader] methods implemented in C.

Member Data Documentation

◆ free

void(* module_loader_t::free) (void *payload)

Frees module loader and all associated memory.

Parameters
[in]payloadThe module loader self pointer

◆ load

intptr_t(* module_loader_t::load) (const void *payload, struct run_context_t *context, struct write_t err)

A function to load the module my making MeTTa API calls.

Parameters
[in]payloadThe module loader self pointer
[in]run_contextThe run_context_t to provide access to the MeTTa run interface
[in]errThe writer to fill with error message if any
Returns
0 if success, non-zero otherwise; code should put the explanation text to the err field.

◆ load_tokens

intptr_t(* module_loader_t::load_tokens) (const void *payload, struct metta_mod_ref_t target, struct metta_t metta, struct write_t err)

Loads module's tokens into target module. This method is used for both initial token loading and exporting module's tokens into importing module.

Parameters
[in]payloadThe module loader self pointer
[in]targetThe module to load tokens into
[in]mettaThe context MeTTa runner
[in]errThe writer to fill with error message if any
Returns
0 if success, non-zero otherwise; code should put the explanation text to the err field.

◆ to_string

void(* module_loader_t::to_string) (const void *payload, struct write_t text)

Prints module loader content as a string, used for implementing [std::fmt::Debug].

Parameters
[in]payloadThe module loader self pointer
[in]textObject to write the text into

The documentation for this struct was generated from the following file: