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

A table of functions to load MeTTa modules from an arbitrary format. More...

#include <hyperon.h>

Public Attributes

uintptr_t(* path_for_name )(const void *payload, const char *parent_dir, const char *mod_name, char *dst_buf, uintptr_t buf_size)
 Constructs a path for a module with a given name that resides in a parent directory.
bool(* try_path )(const void *payload, const char *path, const char *mod_name, const struct module_loader_t **mod_loader, struct module_descriptor_t *mod_descriptor)
 Tests a path in the file system to determine if a valid module resides at the path.
void(* free )(void *payload)
 Frees a user-defined structure that may have been allocated in try_path.

Detailed Description

A table of functions to load MeTTa modules from an arbitrary format.

Warning
All of the functions in this interface may be called from threads outside the main thread, and may be called concurrently. Therefore these functions must be fully reentrant.

Member Data Documentation

◆ free

void(* fs_module_format_t::free) (void *payload)

Frees a user-defined structure that may have been allocated in try_path.

Parameters
[in]callback_contextThe value returned from try_path, if it was non-NULL

◆ path_for_name

uintptr_t(* fs_module_format_t::path_for_name) (const void *payload, const char *parent_dir, const char *mod_name, char *dst_buf, uintptr_t buf_size)

Constructs a path for a module with a given name that resides in a parent directory.

Parameters
[in]payloadThe reference to the this instance of the fs_module_format_t
[in]parent_dirA NULL-terminated string, representing the path to the parent directory in the file system
[in]mod_nameA NULL-terminated string, representing the name of the module
[out]dst_bufThe buffer into which to write the output path, followed by a NULL character
[in]buf_sizeThe size of the allocated dst_buf. This function must not overwrite the output buffer
Returns
the number of bytes written into the dst_buf by the function, including a NULL terminator character. If the path does not fit in the dst_buf, then this function should return 0
Note
The implementation does not need to check the validity of the returned path. Results from this method will be passed to try_path to perform validity checking

◆ try_path

bool(* fs_module_format_t::try_path) (const void *payload, const char *path, const char *mod_name, const struct module_loader_t **mod_loader, struct module_descriptor_t *mod_descriptor)

Tests a path in the file system to determine if a valid module resides at the path.

Parameters
[in]payloadThe reference to the this instance of the fs_module_format_t
[in]pathA NULL-terminated string, representing a path in the file system to test
[in]mod_nameA NULL-terminated string, representing the name of the module
[out]mod_loaderA module loader instance owned by caller
[out]mod_descriptorA module descriptor instance owned by caller
Returns
bool true if the path contains a valid module in the format, otherwise false.

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