1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 23:42:43 +01:00

C api: nix_export_std_string -> nix_observe_string

This commit is contained in:
José Luis Lafuente 2024-03-27 17:50:36 +01:00
parent 940ff6535c
commit d96b52bd8b
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
8 changed files with 92 additions and 76 deletions

View file

@ -56,26 +56,24 @@ void nix_store_free(Store * store)
delete store;
}
nix_err nix_store_get_uri(nix_c_context * context, Store * store, char * dest, unsigned int n)
nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callback, void * user_data)
{
if (context)
context->last_err_code = NIX_OK;
try {
auto res = store->ptr->getUri();
return nix_export_std_string(context, res, dest, n);
return call_nix_observe_string(res, callback, user_data);
}
NIXC_CATCH_ERRS
}
nix_err nix_store_get_version(nix_c_context * context, Store * store, char * dest, unsigned int n)
nix_err nix_store_get_version(nix_c_context * context, Store * store, void * callback, void * user_data)
{
if (context)
context->last_err_code = NIX_OK;
try {
auto res = store->ptr->getVersion();
if (!res)
res = "";
return nix_export_std_string(context, *res, dest, n);
return call_nix_observe_string(res.value_or(""), callback, user_data);
}
NIXC_CATCH_ERRS
}

View file

@ -71,11 +71,12 @@ void nix_store_free(Store * store);
* @brief get the URI of a nix store
* @param[out] context Optional, stores error information
* @param[in] store nix store reference
* @param[out] dest The allocated area to write the string to.
* @param[in] n Maximum size of the returned string.
* @param[in] callback Called with the URI.
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
* @see nix_observe_string
* @return error code, NIX_OK on success.
*/
nix_err nix_store_get_uri(nix_c_context * context, Store * store, char * dest, unsigned int n);
nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callback, void * user_data);
// returns: owned StorePath*
/**
@ -130,11 +131,12 @@ nix_err nix_store_realise(
* If the store doesn't have a version (like the dummy store), returns an empty string.
* @param[out] context Optional, stores error information
* @param[in] store nix store reference
* @param[out] dest The allocated area to write the string to.
* @param[in] n Maximum size of the returned string.
* @param[in] callback Called with the version.
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
* @see nix_observe_string
* @return error code, NIX_OK on success.
*/
nix_err nix_store_get_version(nix_c_context *, Store * store, char * dest, unsigned int n);
nix_err nix_store_get_version(nix_c_context * context, Store * store, void * callback, void * user_data);
// cffi end
#ifdef __cplusplus