pub trait Backend:
Sized
+ Send
+ Sync {
const DEFAULT_PATH: &'static str;
const CACHE_PATHS: &'static [&'static str];
// Required methods
fn path(&self) -> &Path;
fn init(
project: &Project,
) -> impl Future<Output = Result<Self, FailToInitBackend>> + Send;
fn supports(&self, platform: TargetPlatform) -> bool;
fn build(
&self,
project: &Project,
platform: TargetPlatform,
options: BuildOptions,
) -> impl Future<Output = Result<PathBuf>> + Send;
fn package(
&self,
project: &Project,
platform: TargetPlatform,
options: PackageOptions,
) -> impl Future<Output = Result<Artifact>> + Send;
fn clean(
&self,
project: &Project,
platform: TargetPlatform,
) -> impl Future<Output = Result<()>> + Send;
}Expand description
Trait for backends in a WaterUI project.
A backend handles building and packaging for specific platforms. Each backend knows:
- Which platforms it supports
- How to build Rust code for those platforms
- How to package artifacts for distribution
Required Associated Constants§
Sourceconst DEFAULT_PATH: &'static str
const DEFAULT_PATH: &'static str
The default relative path for this backend (e.g., “android”, “apple”).
Sourceconst CACHE_PATHS: &'static [&'static str]
const CACHE_PATHS: &'static [&'static str]
Paths relative to the backend directory that should be preserved during re-scaffolding.
These typically contain build caches that are expensive to regenerate.
During reinit_backend(), only items NOT in this list are deleted before calling init().
Required Methods§
Sourcefn path(&self) -> &Path
fn path(&self) -> &Path
Get the relative path for this backend instance.
This is relative to Backends::path().
Sourcefn init(
project: &Project,
) -> impl Future<Output = Result<Self, FailToInitBackend>> + Send
fn init( project: &Project, ) -> impl Future<Output = Result<Self, FailToInitBackend>> + Send
Initialize the backend for the given project.
Creates necessary files/folders for the backend at project.backend_path::<Self>().
Returns the initialized backend configuration.
Sourcefn supports(&self, platform: TargetPlatform) -> bool
fn supports(&self, platform: TargetPlatform) -> bool
Check if this backend supports the given platform.
Sourcefn build(
&self,
project: &Project,
platform: TargetPlatform,
options: BuildOptions,
) -> impl Future<Output = Result<PathBuf>> + Send
fn build( &self, project: &Project, platform: TargetPlatform, options: BuildOptions, ) -> impl Future<Output = Result<PathBuf>> + Send
Build the Rust library for the target platform.
Returns the target directory path where the built library is located.
Sourcefn package(
&self,
project: &Project,
platform: TargetPlatform,
options: PackageOptions,
) -> impl Future<Output = Result<Artifact>> + Send
fn package( &self, project: &Project, platform: TargetPlatform, options: PackageOptions, ) -> impl Future<Output = Result<Artifact>> + Send
Package the project for the target platform.
Returns the artifact (e.g., .app, .apk, binary).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".