tinymist_project::world

Struct CompilerWorld

pub struct CompilerWorld<F>
where F: CompilerFeat,
{ pub library: Arc<LazyHash<Library>>, pub font_resolver: Arc<<F as CompilerFeat>::FontResolver>, pub registry: Arc<<F as CompilerFeat>::Registry>, /* private fields */ }

Fields§

§library: Arc<LazyHash<Library>>

Provides library for typst compiler.

§font_resolver: Arc<<F as CompilerFeat>::FontResolver>

Provides font management for typst compiler.

§registry: Arc<<F as CompilerFeat>::Registry>

Provides package management for typst compiler.

Implementations§

§

impl<F> CompilerWorld<F>
where F: CompilerFeat,

pub fn task(&self, mutant: TaskInputs) -> CompilerWorld<F>

pub fn take_cache(&mut self) -> SourceCache

pub fn clone_cache(&mut self) -> SourceCache

pub fn take_db(&mut self) -> SourceDb

pub fn vfs(&self) -> &Vfs<<F as CompilerFeat>::AccessModel>

pub fn set_is_compiling(&mut self, is_compiling: bool)

Sets flag to indicate whether the compiler is currently compiling. Note: Since CompilerWorld can be cloned, you can clone the world and set the flag then to avoid affecting the original world.

pub fn inputs(&self) -> Arc<LazyHash<Dict>>

pub fn path_for_id(&self, id: FileId) -> Result<PathResolution, FileError>

Resolve the real path for a file id.

pub fn id_for_path(&self, path: &Path) -> Option<FileId>

Resolve the root of the workspace.

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

pub fn evict_vfs(&mut self, threshold: usize)

pub fn evict_source_cache(&mut self, threshold: usize)

pub 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.

pub fn paged_task(&self) -> Cow<'_, CompilerWorld<F>>

pub fn html_task(&self) -> Cow<'_, CompilerWorld<F>>

Trait Implementations§

§

impl<F> Clone for CompilerWorld<F>
where F: CompilerFeat,

§

fn clone(&self) -> CompilerWorld<F>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<F> EntryReader for CompilerWorld<F>
where F: CompilerFeat,

§

fn entry_state(&self) -> EntryState

§

fn main_id(&self) -> Option<FileId>

§

impl<'a, F> Files<'a> for CompilerWorld<F>
where F: CompilerFeat,

§

type FileId = FileId

A unique identifier for files in the file provider. This will be used for rendering diagnostic::Labels in the corresponding source files.

§

type Name = String

The user-facing name of a file, to be displayed in diagnostics.

§

type Source = Source

The source code of a file.

§

fn name( &'a self, id: FileId, ) -> Result<<CompilerWorld<F> as Files<'a>>::Name, Error>

The user-facing name of a file.

§

fn source( &'a self, id: FileId, ) -> Result<<CompilerWorld<F> as Files<'a>>::Source, Error>

The source code of a file.

§

fn line_index(&'a self, id: FileId, given: usize) -> Result<usize, Error>

See [codespan_reporting::files::Files::line_index].

§

fn column_number( &'a self, id: FileId, _: usize, given: usize, ) -> Result<usize, Error>

See [codespan_reporting::files::Files::column_number].

§

fn line_range(&'a self, id: FileId, given: usize) -> Result<Range<usize>, Error>

See [codespan_reporting::files::Files::line_range].

§

fn line_number( &'a self, id: Self::FileId, line_index: usize, ) -> Result<usize, Error>

The user-facing line number at the given line index. It is not necessarily checked that the specified line index is actually in the file. Read more
§

fn location( &'a self, id: Self::FileId, byte_index: usize, ) -> Result<Location, Error>

Convenience method for returning line and column number at the given byte index in the file.
§

impl<F> FsProvider for CompilerWorld<F>
where F: CompilerFeat,

§

fn file_path(&self, file_id: FileId) -> Result<PathResolution, FileError>

Arbitrary one of file path corresponding to the given id.
§

fn read(&self, file_id: FileId) -> Result<Bytes, FileError>

§

fn read_source(&self, file_id: FileId) -> Result<Source, FileError>

§

impl<F> ShadowApi for CompilerWorld<F>
where F: CompilerFeat,

§

fn shadow_ids(&self) -> Vec<FileId>

Get the shadow files by file id.
§

fn shadow_paths(&self) -> Vec<Arc<Path>>

Get the shadow files.
§

fn reset_shadow(&mut self)

Reset the shadow files.
§

fn map_shadow(&mut self, path: &Path, content: Bytes) -> Result<(), FileError>

Add a shadow file to the driver.
§

fn unmap_shadow(&mut self, path: &Path) -> Result<(), FileError>

Add a shadow file to the driver.
§

fn map_shadow_by_id( &mut self, file_id: FileId, content: Bytes, ) -> Result<(), FileError>

Add a shadow file to the driver by file id. Note: If a path is both shadowed by id and by path, the shadow by id will be used.
§

fn unmap_shadow_by_id(&mut self, file_id: FileId) -> Result<(), FileError>

Add a shadow file to the driver by file id. Note: If a path is both shadowed by id and by path, the shadow by id will be used.
§

impl<F> SourceWorld for CompilerWorld<F>
where F: CompilerFeat,

§

fn path_for_id(&self, id: FileId) -> Result<PathResolution, FileError>

Resolve the real path for a file id.

§

fn as_world(&self) -> &dyn World

§

fn lookup(&self, id: FileId) -> Source

§

impl<F> World for CompilerWorld<F>
where F: CompilerFeat,

§

fn library(&self) -> &LazyHash<Library>

The standard library.

§

fn main(&self) -> FileId

Access the main source file.

§

fn font(&self, id: usize) -> Option<Font>

Metadata about all known fonts.

§

fn book(&self) -> &LazyHash<FontBook>

Try to access the specified file.

§

fn source(&self, id: FileId) -> Result<Source, FileError>

Try to access the specified source file.

The returned Source file’s id does not have to match the given id. Due to symlinks, two different file id’s can point to the same on-disk file. Implementers can deduplicate and return the same Source if they want to, but do not have to.

§

fn file(&self, id: FileId) -> Result<Bytes, FileError>

Try to access the specified file.

§

fn today(&self, offset: Option<i64>) -> Option<Datetime>

Get the current date.

If no offset is specified, the local date should be chosen. Otherwise, the UTC date should be chosen with the corresponding offset in hours.

If this function returns None, Typst’s datetime function will return an error.

§

impl<F> WorldDeps for CompilerWorld<F>
where F: CompilerFeat,

§

fn iter_dependencies(&self, f: &mut dyn FnMut(FileId))

Auto Trait Implementations§

§

impl<F> !Freeze for CompilerWorld<F>

§

impl<F> !RefUnwindSafe for CompilerWorld<F>

§

impl<F> Send for CompilerWorld<F>

§

impl<F> Sync for CompilerWorld<F>

§

impl<F> Unpin for CompilerWorld<F>

§

impl<F> !UnwindSafe for CompilerWorld<F>

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<S, T> ArcInto<T> for S
where Arc<S>: Into<T>,

§

fn arc_into(self: Arc<S>) -> T

Converts Arc<T> into Self.
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> Filterable for T

§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<C> ShadowApiExt for C
where C: ShadowApi,

§

fn with_shadow_file<T>( &mut self, file_path: &Path, content: Bytes, f: impl FnOnce(&mut C) -> Result<T, EcoVec<SourceDiagnostic>>, ) -> Result<T, EcoVec<SourceDiagnostic>>

Wrap the driver with a given shadow file and run the inner function.

§

fn with_shadow_file_by_id<T>( &mut self, file_id: FileId, content: Bytes, f: impl FnOnce(&mut C) -> Result<T, EcoVec<SourceDiagnostic>>, ) -> Result<T, EcoVec<SourceDiagnostic>>

Wrap the driver with a given shadow file and run the inner function by file id. Note: to enable this function, ShadowApi must implement _shadow_map_id.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WorldExt for T
where T: World + ?Sized,

§

fn range(&self, span: Span) -> Option<Range<usize>>

Get the byte range for a span. Read more
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,