[Libguestfs] [nbdkit PATCH v3 14/14] ocaml: Implement .list_exports and friends

Richard W.M. Jones rjones at redhat.com
Tue Sep 22 11:04:27 UTC 2020


On Mon, Sep 21, 2020 at 11:23:58AM -0500, Eric Blake wrote:
> diff --git a/plugins/ocaml/example.ml b/plugins/ocaml/example.ml
> index 448de8c4..de493bf2 100644
> --- a/plugins/ocaml/example.ml
> +++ b/plugins/ocaml/example.ml
> @@ -41,6 +41,13 @@ let ocamlexample_config key value =
>    | _ ->
>       failwith (Printf.sprintf "unknown parameter: %s" key)
> 
> +let ocamlexample_list_exports ro tls : NBDKit.export list =
> +  [ { name = "name1"; description = Some "desc1" };
> +    { name = "name2"; description = None } ]
> +
> +let ocamlexample_default_export ro tls =
> +  "name1"

It's optional, but if you don't care about a particular parameter you
can use a single underscore, as in:

let ocamlexample_default_export _ _ =
  "name1"

I'm sure it's possible to get OCaml to warn about unused non-“_”
parameters, but we have that warning turned off because it'd be quite
annoying.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list