Re: [PATCH 3/3] ruby: add db.{set,get}_config

Subject: Re: [PATCH 3/3] ruby: add db.{set,get}_config

Date: Mon, 29 May 2023 08:32:29 -0300

To: Felipe Contreras, notmuch@notmuchmail.org

Cc:

From: David Bremner


Felipe Contreras <felipe.contreras@gmail.com> writes:

> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  bindings/ruby/database.c | 45 ++++++++++++++++++++++++++++++++++++++++
>  bindings/ruby/defs.h     |  6 ++++++
>  bindings/ruby/init.c     |  2 ++
>  3 files changed, 53 insertions(+)

So, usual request about tests...


> +/*
> + * call-seq: DB.get_config(key) => String
> + *
> + * Retrieves a configuration key.
> + */
> +VALUE
> +notmuch_rb_database_get_config (VALUE self, VALUE key)
> +{
> +    notmuch_database_t *db;
> +    notmuch_status_t ret;
> +    char *value;
> +    VALUE rvalue;
> +
> +    Data_Get_Notmuch_Database (self, db);
> +
> +    ret = notmuch_database_get_config (db, RSTRING_PTR (key), &value);
> +    notmuch_rb_status_raise (ret);
> +
> +    rvalue = rb_str_new2 (value);
> +    free (value);
> +
> +    return rvalue;
> +}

Just to be clear, there are (confusingly) two APIs for reading
configuration. The one you are binding is in some sense the most low
level and general but it might be good to encourage use of
notmuch_config_get, since the use of an enum makes it less error-prone
for well-known configuration values.
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: