tinymist_project::world::package

Trait PackageRegistry

pub trait PackageRegistry {
    // Required method
    fn resolve(&self, spec: &PackageSpec) -> Result<Arc<Path>, PackageError>;

    // Provided methods
    fn reset(&mut self) { ... }
    fn revision(&self) -> Option<NonZero<usize>> { ... }
    fn packages(&self) -> &[(PackageSpec, Option<EcoString>)] { ... }
}
Expand description

A trait for package registries.

Required Methods§

fn resolve(&self, spec: &PackageSpec) -> Result<Arc<Path>, PackageError>

Resolves a package specification to a local path.

Provided Methods§

fn reset(&mut self)

A function to be called when the registry is reset.

fn revision(&self) -> Option<NonZero<usize>>

If the state of package registry can be well-defined by a revision, it should return it. This is used to determine if the compiler should clean and pull the registry again.

fn packages(&self) -> &[(PackageSpec, Option<EcoString>)]

A list of all available packages and optionally descriptions for them.

This function is optional to implement. It enhances the user experience by enabling autocompletion for packages. Details about packages from the @preview namespace are available from https://packages.typst.org/preview/index.json.

Implementors§