Nix 2.35.2
Nix, the purely functional package manager: C API (experimental)
Loading...
Searching...
No Matches
NixCExternalValueDesc Struct Reference

Definition for a class of external values. More...

#include <nix_api_external.h>

Data Fields

void(*) print (void *self, nix_printer *printer)
 Called when printing the external value.
void(*) showType (void *self, nix_string_return *res)
 Called on :t.
void(*) typeOf (void *self, nix_string_return *res)
 Called on builtins.typeOf.
void(*) coerceToString (void *self, nix_string_context *c, int coerceMore, int copyToStore, nix_string_return *res)
 Called on "${str}" and builtins.toString.
int(*) equal (void *self, void *other)
 Try to compare two external values.
void(*) printValueAsJSON (void *self, EvalState *state, bool strict, nix_string_context *c, bool copyToStore, nix_string_return *res)
 Convert the external value to json.
void(*) printValueAsXML (void *self, EvalState *state, int strict, int location, void *doc, nix_string_context *c, void *drvsSeen, int pos)
 Convert the external value to XML.

Detailed Description

Definition for a class of external values.

Create and implement one of these, then pass it to nix_create_external_value Make sure to keep it alive while the external value lives.

Optional functions can be set to NULL

See also
nix_create_external_value

Field Documentation

◆ coerceToString

void(*) NixCExternalValueDesc::coerceToString(void *self, nix_string_context *c, int coerceMore, int copyToStore, nix_string_return *res)

Called on "${str}" and builtins.toString.

The latter with coerceMore=true Optional, the default is to throw an error.

Parameters
[in]selfthe void* passed to nix_create_external_value
[out]cwritable string context for the resulting string
[in]coerceMoreboolean, try to coerce to strings in more cases instead of throwing an error
[in]copyToStoreboolean, whether to copy referenced paths to store or keep them as-is
[out]resthe return value. Not touching this, or setting it to the empty string, will make the conversion throw an error.

◆ equal

int(*) NixCExternalValueDesc::equal(void *self, void *other)

Try to compare two external values.

Optional, the default is always false. If the other object was not a Nix C API external value, this comparison will also return false

Parameters
[in]selfthe void* passed to nix_create_external_value
[in]otherthe void* passed to the other object's nix_create_external_value
Returns
true if the objects are deemed to be equal

◆ print

void(*) NixCExternalValueDesc::print(void *self, nix_printer *printer)

Called when printing the external value.

Parameters
[in]selfthe void* passed to nix_create_external_value
[out]printerThe printer to print to, pass to nix_external_print

◆ printValueAsJSON

void(*) NixCExternalValueDesc::printValueAsJSON(void *self, EvalState *state, bool strict, nix_string_context *c, bool copyToStore, nix_string_return *res)

Convert the external value to json.

Optional, the default is to throw an error

Parameters
[in]selfthe void* passed to nix_create_external_value
[in]stateThe evaluator state
[in]strictboolean Whether to force the value before printing
[out]cwritable string context for the resulting string
[in]copyToStorewhether to copy referenced paths to store or keep them as-is
[out]resthe return value. Gets parsed as JSON. Not touching this, or setting it to the empty string, will make the conversion throw an error.

◆ printValueAsXML

void(*) NixCExternalValueDesc::printValueAsXML(void *self, EvalState *state, int strict, int location, void *doc, nix_string_context *c, void *drvsSeen, int pos)

Convert the external value to XML.

Optional, the default is to throw an error

Todo
The mechanisms for this call are incomplete. There are no C bindings to work with XML, pathsets and positions. This callback also has no test coverage.
Parameters
[in]selfthe void* passed to nix_create_external_value
[in]stateThe evaluator state
[in]strictboolean Whether to force the value before printing
[in]locationboolean Whether to include position information in the xml
[out]docXML document to output to
[out]cwritable string context for the resulting string
[in,out]drvsSeena path set to avoid duplicating derivations
[in]posThe position of the call.

◆ showType

void(*) NixCExternalValueDesc::showType(void *self, nix_string_return *res)

Called on :t.

Parameters
[in]selfthe void* passed to nix_create_external_value
[out]resthe return value

◆ typeOf

void(*) NixCExternalValueDesc::typeOf(void *self, nix_string_return *res)

Called on builtins.typeOf.

Parameters
selfthe void* passed to nix_create_external_value
[out]resthe return value

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