Struct sixtyfps_interpreter::ComponentCompiler [−][src]
pub struct ComponentCompiler { /* fields omitted */ }
ComponentCompiler is the entry point to the SixtyFPS interpreter that can be used to load .60 files or compile them on-the-fly from a string.
Implementations
impl ComponentCompiler
[src]
impl ComponentCompiler
[src]pub fn new() -> Self
[src]
Returns a new ComponentCompiler
pub fn set_include_paths(&mut self, include_paths: Vec<PathBuf>)
[src]
Sets the include paths used for looking up .60
imports to the specified vector of paths.
pub fn include_paths(&self) -> &Vec<PathBuf>
[src]
Returns the include paths the component compiler is currently configured with.
pub fn set_style(&mut self, style: String)
[src]
Sets the style to be used for widgets.
pub fn style(&self) -> Option<&String>
[src]
Returns the widget style the compiler is currently using when compiling .60 files.
pub fn set_file_loader(
&mut self,
file_loader_fallback: impl Fn(&Path) -> Pin<Box<dyn Future<Output = Option<Result<String>>>>> + 'static
)
[src]
&mut self,
file_loader_fallback: impl Fn(&Path) -> Pin<Box<dyn Future<Output = Option<Result<String>>>>> + 'static
)
Sets the callback that will be invoked when loading imported .60 files. The specified
file_loader_callback
parameter will be called with a canonical file path as argument
and is expected to return a future that, when resolved, provides the source code of the
.60 file to be imported as a string.
If an error is returned, then the build will abort with that error.
If None is returned, it means the normal resolution algorithm will proceed as if the hook
was not in place (i.e: load from the file system following the include paths)
pub fn diagnostics(&self) -> &Vec<Diagnostic>
[src]
Returns the diagnostics that were produced in the last call to [Self::build_from_path] or [Self::build_from_source].
pub async fn build_from_path<P: AsRef<Path>>(
&mut self,
path: P
) -> Option<ComponentDefinition>
[src]
&mut self,
path: P
) -> Option<ComponentDefinition>
Compile a .60 file into a ComponentDefinition
Returns the compiled ComponentDefinition
if there were no errors.
Any diagnostics produced during the compilation, such as warnigns or errors, are collected
in this ComponentCompiler and can be retrieved after the call using the [Self::diagnostics()]
function. The print_diagnostics
function can be used to display the diagnostics
to the users.
Diagnostics from previous calls are cleared when calling this function.
This function is async
but in practice, this is only asynchronious if
Self::set_file_loader
was called and its future is actually asynchronious.
If that is not used, then it is fine to use a very simple executor, such as the one
provided by the spin_on
crate
pub async fn build_from_source(
&mut self,
source_code: String,
path: PathBuf
) -> Option<ComponentDefinition>
[src]
&mut self,
source_code: String,
path: PathBuf
) -> Option<ComponentDefinition>
Compile some .60 code into a ComponentDefinition
The path
argument will be used for diagnostics and to compute relative
paths while importing.
Any diagnostics produced during the compilation, such as warnings or errors, are collected
in this ComponentCompiler and can be retrieved after the call using the [Self::diagnostics()]
function. The print_diagnostics
function can be used to display the diagnostics
to the users.
Diagnostics from previous calls are cleared when calling this function.
This function is async
but in practice, this is only asynchronious if
Self::set_file_loader
is set and its future is actually asynchronious.
If that is not used, then it is fine to use a very simple executor, such as the one
provided by the spin_on
crate
Auto Trait Implementations
impl !RefUnwindSafe for ComponentCompiler
impl !RefUnwindSafe for ComponentCompiler
impl !Send for ComponentCompiler
impl !Send for ComponentCompiler
impl !Sync for ComponentCompiler
impl !Sync for ComponentCompiler
impl Unpin for ComponentCompiler
impl Unpin for ComponentCompiler
impl !UnwindSafe for ComponentCompiler
impl !UnwindSafe for ComponentCompiler