pub struct Context { /* private fields */ }
Expand description

Compiling context

This holds global, compiling (local) and versions’ Metadata, snapshot manager. This also provides some helper methods.

Implementations§

source§

impl Context

source

pub fn new(config: Config) -> Self

source

pub async fn metadata(&self) -> Metadata

Get Metadata that merges global and compiling metadata

source

pub fn compiling_metadata(&self) -> Result<&Metadata>

Get compiling Metadata

source

pub async fn insert_global_metadata( &self, name: impl ToString, value: impl Serialize ) -> Result<()>

Insert global Metadata

You can pass anything which can be serialized and deserialized to serde_json::Value.

source

pub fn insert_compiling_metadata( &mut self, name: impl ToString, value: impl Serialize ) -> Result<()>

Insert compiling Metadata

You can pass anything which can be serialized and deserialized to serde_json::Value.

source

pub async fn insert_global_raw_metadata( &self, name: impl ToString, metadata: Metadata )

Insert raw Metadata value to global metadata

source

pub fn insert_compiling_raw_metadata( &mut self, name: impl ToString, metadata: Metadata ) -> Result<()>

Insert raw Metadata value to compiling metadata

source

pub fn version(&self) -> Result<Version>

Get currently compiling Version

source

pub async fn get_version_metadata( &self, version: impl Into<Version>, path: &PathBuf ) -> Option<Metadata>

Get specified Version and source’s metadata’

source

pub async fn insert_version( &self, version: impl Into<Version>, path: PathBuf, metadata: Metadata ) -> Result<()>

Insert specified Version and source’s metadata

source

pub async fn wait_snapshot_until( &self, name: impl ToString, stage: usize ) -> Result<()>

Wait snapshot until specified stage. In most cases, you would like to wait until stage 1, that means “first snapshot was taken”.

source

pub async fn save_snapshot(&self) -> Result<()>

Save currently compiling Metadata as snapshot

source

pub fn rule(&self) -> Result<String>

Get currently compiling rule name

source

pub fn source(&self) -> Result<PathBuf>

Get currently compiling source file path

source

pub fn target(&self) -> Result<PathBuf>

Get currently compiling target file path

source

pub fn path(&self) -> Result<PathBuf>

Get currently compiling URL path

source

pub fn body(&self) -> Result<Metadata>

Get currently compiling body Metadata, which can be Vec<u8> or String.

source

pub fn config(&self) -> Config

Get Config

source

pub fn get_source_body(&self) -> Result<Vec<u8>>

Get source file body as bytes

source

pub fn get_source_string(&self) -> Result<String>

Get source file string

source

pub fn get_source_data(&self) -> Result<Metadata>

Get source file data as Metadata

source

pub fn create_target_parent_dir(&self) -> Result<()>

Create target file’s parent directory

source

pub fn open_target(&self) -> Result<File>

Open target file to write

Trait Implementations§

source§

impl Clone for Context

source§

fn clone(&self) -> Context

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

§

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
source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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

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

§

fn vzip(self) -> V