pub trait Platform: Send + Sync {
type Toolchain: Toolchain;
type Device: Device;
// Required methods
fn clean(
&self,
project: &Project,
) -> impl Future<Output = Result<()>> + Send;
fn package(
&self,
project: &Project,
options: PackageOptions,
) -> impl Future<Output = Result<Artifact>> + Send;
fn toolchain(&self) -> Self::Toolchain;
fn scan(&self) -> impl Future<Output = Result<Vec<Self::Device>>> + Send;
fn triple(&self) -> Triple;
fn build(
&self,
project: &Project,
options: BuildOptions,
) -> impl Future<Output = Result<PathBuf>> + Send;
}Expand description
Trait representing a specific platform (e.g., Android, iOS, etc.)
Note: Platform would never check toolchain since it is the responsibility of the Toolchain.
We assume the toolchain is already set up correctly when calling methods of this trait.
Required Associated Types§
Required Methods§
Sourcefn clean(&self, project: &Project) -> impl Future<Output = Result<()>> + Send
fn clean(&self, project: &Project) -> impl Future<Output = Result<()>> + Send
Clean build artifacts for this platform (not include rust build artifacts)
Sourcefn package(
&self,
project: &Project,
options: PackageOptions,
) -> impl Future<Output = Result<Artifact>> + Send
fn package( &self, project: &Project, options: PackageOptions, ) -> impl Future<Output = Result<Artifact>> + Send
Package the project for this platform
Return the path to the packaged file
§Warnings
You should call build before calling this method to ensure the project is built for the platform.
Sourcefn scan(&self) -> impl Future<Output = Result<Vec<Self::Device>>> + Send
fn scan(&self) -> impl Future<Output = Result<Vec<Self::Device>>> + Send
Scan for connected devices for this platform
Sourcefn build(
&self,
project: &Project,
options: BuildOptions,
) -> impl Future<Output = Result<PathBuf>> + Send
fn build( &self, project: &Project, options: BuildOptions, ) -> impl Future<Output = Result<PathBuf>> + Send
Build the Rust library for this platform
Warning: This method would build and copy the built library to the appropriate location in the project directory. However, it does not handle hot reload library building or management.
Return the target directory path where the built library is located.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.