Module Test_interfaces.Directory_reader

A directory reader is a Trait that is able to list all the entries contained in a directory in the file system.

type tag = [
  1. | `Directory_reader
]

The tag is used as a phantom type to characterize the nature of the specific provider that this library needs.

type 'a t = [> tag ] as 'a Provider.packed

This library can operate on any provider, as long as it implements at least the `Directory_reader capability.

val readdir : _ t -> path:Base.string -> Base.string Base.list

This function will result in calling the method readdir implemented by the provider.

val find_files_with_extension : _ t -> path:Base.string -> ext:Base.string -> Base.string Base.list

This function will result in calling the method readdir implemented by the provider, and then filtering the results to only keep the files with the given extension. This shows an example of a function that is implemented on top of a minimal interface furnished by a provider. Its implementation is shared across providers, since it lives in the implementation of this module.

Building providers

module Provider_interface : sig ... end

Such abstraction will export a way for implementers (providers) to provide the implementation required by that interface. In Eio naming conventions, these modules are typically named Pi.