mobench_sdk/
types.rs

1//! Core types for bench-sdk
2//!
3//! This module re-exports types from mobench-runner and adds SDK-specific types.
4
5// Re-export mobench-runner types for convenience
6pub use mobench_runner::{
7    BenchError as RunnerError, BenchReport as RunnerReport, BenchSample, BenchSpec,
8};
9
10use std::path::PathBuf;
11
12/// Error types for bench-sdk operations
13#[derive(Debug, thiserror::Error)]
14pub enum BenchError {
15    /// Error from the benchmark runner
16    #[error("runner error: {0}")]
17    Runner(#[from] mobench_runner::BenchError),
18
19    /// Benchmark function not found in registry
20    #[error("unknown benchmark function: {0}")]
21    UnknownFunction(String),
22
23    /// Error during benchmark execution
24    #[error("execution error: {0}")]
25    Execution(String),
26
27    /// I/O error
28    #[error("I/O error: {0}")]
29    Io(#[from] std::io::Error),
30
31    /// Serialization error
32    #[error("serialization error: {0}")]
33    Serialization(#[from] serde_json::Error),
34
35    /// Configuration error
36    #[error("configuration error: {0}")]
37    Config(String),
38
39    /// Build error
40    #[error("build error: {0}")]
41    Build(String),
42}
43
44/// Target platform for benchmarks
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46pub enum Target {
47    /// Android platform
48    Android,
49    /// iOS platform
50    Ios,
51    /// Both platforms
52    Both,
53}
54
55impl Target {
56    pub fn as_str(&self) -> &'static str {
57        match self {
58            Target::Android => "android",
59            Target::Ios => "ios",
60            Target::Both => "both",
61        }
62    }
63}
64
65/// Configuration for initializing a benchmark project
66#[derive(Debug, Clone)]
67pub struct InitConfig {
68    /// Target platform(s)
69    pub target: Target,
70    /// Project name
71    pub project_name: String,
72    /// Output directory for generated files
73    pub output_dir: PathBuf,
74    /// Whether to generate example benchmarks
75    pub generate_examples: bool,
76}
77
78/// Configuration for building mobile apps
79#[derive(Debug, Clone)]
80pub struct BuildConfig {
81    /// Target platform
82    pub target: Target,
83    /// Build profile (debug or release)
84    pub profile: BuildProfile,
85    /// Whether to skip build if artifacts exist
86    pub incremental: bool,
87}
88
89/// Build profile
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
91pub enum BuildProfile {
92    /// Debug build
93    Debug,
94    /// Release build
95    Release,
96}
97
98impl BuildProfile {
99    pub fn as_str(&self) -> &'static str {
100        match self {
101            BuildProfile::Debug => "debug",
102            BuildProfile::Release => "release",
103        }
104    }
105}
106
107/// Result of a build operation
108#[derive(Debug, Clone)]
109pub struct BuildResult {
110    /// Platform that was built
111    pub platform: Target,
112    /// Path to the app artifact (APK, IPA, etc.)
113    pub app_path: PathBuf,
114    /// Path to the test suite artifact (if applicable)
115    pub test_suite_path: Option<PathBuf>,
116}