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
impl Context
pub fn new(config: Config) -> Self
sourcepub async fn metadata(&self) -> Metadata
pub async fn metadata(&self) -> Metadata
Get Metadata
that merges global and compiling metadata
sourcepub fn compiling_metadata(&self) -> Result<&Metadata>
pub fn compiling_metadata(&self) -> Result<&Metadata>
Get compiling Metadata
sourcepub async fn insert_global_metadata(
&self,
name: impl ToString,
value: impl Serialize
) -> Result<()>
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
.
sourcepub fn insert_compiling_metadata(
&mut self,
name: impl ToString,
value: impl Serialize
) -> Result<()>
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
.
sourcepub async fn insert_global_raw_metadata(
&self,
name: impl ToString,
metadata: Metadata
)
pub async fn insert_global_raw_metadata( &self, name: impl ToString, metadata: Metadata )
Insert raw Metadata
value to global metadata
sourcepub fn insert_compiling_raw_metadata(
&mut self,
name: impl ToString,
metadata: Metadata
) -> Result<()>
pub fn insert_compiling_raw_metadata( &mut self, name: impl ToString, metadata: Metadata ) -> Result<()>
Insert raw Metadata
value to compiling metadata
sourcepub async fn get_version_metadata(
&self,
version: impl Into<Version>,
path: &PathBuf
) -> Option<Metadata>
pub async fn get_version_metadata( &self, version: impl Into<Version>, path: &PathBuf ) -> Option<Metadata>
Get specified Version
and source’s metadata’
sourcepub async fn insert_version(
&self,
version: impl Into<Version>,
path: PathBuf,
metadata: Metadata
) -> Result<()>
pub async fn insert_version( &self, version: impl Into<Version>, path: PathBuf, metadata: Metadata ) -> Result<()>
Insert specified Version
and source’s metadata
sourcepub async fn wait_snapshot_until(
&self,
name: impl ToString,
stage: usize
) -> Result<()>
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”.
sourcepub async fn save_snapshot(&self) -> Result<()>
pub async fn save_snapshot(&self) -> Result<()>
Save currently compiling Metadata
as snapshot
sourcepub fn get_source_body(&self) -> Result<Vec<u8>>
pub fn get_source_body(&self) -> Result<Vec<u8>>
Get source file body as bytes
sourcepub fn get_source_string(&self) -> Result<String>
pub fn get_source_string(&self) -> Result<String>
Get source file string
sourcepub fn get_source_data(&self) -> Result<Metadata>
pub fn get_source_data(&self) -> Result<Metadata>
Get source file data as Metadata
sourcepub fn create_target_parent_dir(&self) -> Result<()>
pub fn create_target_parent_dir(&self) -> Result<()>
Create target file’s parent directory
sourcepub fn open_target(&self) -> Result<File>
pub fn open_target(&self) -> Result<File>
Open target file to write