Skip to main content

CompilationTarget

Trait CompilationTarget 

Source
pub trait CompilationTarget {
    type Compiler: ArtifactCompiler;
    type Loaded: Clone;

    // Required methods
    fn compiler(&self) -> &Self::Compiler;
    fn persists(&self) -> bool;
    fn stored(
        &mut self,
        id: &ArtifactId<VariantOf<Self>>,
    ) -> Option<ArtifactOf<Self>>;
    fn load(
        &mut self,
        id: &ArtifactId<VariantOf<Self>>,
        artifact: &ArtifactOf<Self>,
    ) -> Result<Self::Loaded, CompilationError>;
    fn store(
        &mut self,
        id: &ArtifactId<VariantOf<Self>>,
        artifact: ArtifactOf<Self>,
        source: Option<&str>,
    ) -> bool;

    // Provided method
    fn stored_for_source(&mut self, source: &str) -> Option<ArtifactOf<Self>> { ... }
}
Expand description

The half of a backend’s compilation that runs only where the server does: the compilation store, and the loads on the server’s context.

Required Associated Types§

Source

type Compiler: ArtifactCompiler

The half that may run on any thread.

Source

type Loaded: Clone

What a launch dispatches. Cloned on every launch, so it should be handles and shared pointers.

Required Methods§

Source

fn compiler(&self) -> &Self::Compiler

The half that may run on any thread.

Source

fn persists(&self) -> bool

Whether artifacts are kept between runs, which is what binds the loaded kernels to the active environment: a switch replaces the store they mirror, so the KernelLoader drops them.

Source

fn stored( &mut self, id: &ArtifactId<VariantOf<Self>>, ) -> Option<ArtifactOf<Self>>

Takes the artifact the compilation store holds for id out of it, to be loaded; None when there is no store or it holds nothing for id.

Source

fn load( &mut self, id: &ArtifactId<VariantOf<Self>>, artifact: &ArtifactOf<Self>, ) -> Result<Self::Loaded, CompilationError>

Loads artifact on the device.

Source

fn store( &mut self, id: &ArtifactId<VariantOf<Self>>, artifact: ArtifactOf<Self>, source: Option<&str>, ) -> bool

Keeps a loaded artifact in the compilation store under id and, when given, under the source it was finalized from. Whether the store took it, as store_compiled answers: false with no store.

Called after load, so an artifact the device refused is never handed back on the next run.

Provided Methods§

Source

fn stored_for_source(&mut self, source: &str) -> Option<ArtifactOf<Self>>

Takes the artifact the compilation store holds for another kernel finalized from source out of it — see ArtifactCompiler::source — for store to put back under the kernel asking. None, the default, for a backend that keeps no artifact by source.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§