File.Request
Request objects that can be optionally used with this module.
This is a binding to uv_fs_t
.
By default, request objects are managed internally by Luv, and the user does not need to be aware of them. The only purpose of exposing them in the API is to allow the user to cancel filesystem operations.
All functions in this module that start asynchronous operations take a reference to a request object in a ?request
optional argument. If the user does provide a request object, Luv will use that object for the operation, instead of creating a fresh request object internally. The user can then cancel the operation by calling Luv.Request.cancel
on the request:
let request = Luv.File.Request.make () in
Luv.File.chmod ~request "foo" [`IRUSR] ignore;
ignore (Luv.Request.cancel request);
This mechanism is entirely optional. If cancelation is not needed, the code reduces to simply
Luv.File.chmod "foo" [`IRUSR] ignore;