lingxia_platform/traits/
device.rs1use crate::error::PlatformError;
2use crate::{DeviceInfo, ScreenInfo};
3
4pub trait Device: Send + Sync + 'static {
5 fn device_info(&self) -> DeviceInfo;
6 fn screen_info(&self) -> ScreenInfo;
7 fn vibrate(&self, long: bool) -> Result<(), PlatformError>;
8 fn make_phone_call(&self, phone_number: &str) -> Result<(), PlatformError>;
9}
10
11pub trait DeviceHardware: Send + Sync + 'static {
12 fn get_memory_info(&self) -> Result<u64, PlatformError> {
14 Err(PlatformError::NotSupported(
15 "get_memory_info not implemented".to_string(),
16 ))
17 }
18
19 fn get_cpu_count(&self) -> usize {
21 std::thread::available_parallelism()
22 .map(|count| count.get())
23 .unwrap_or(1)
24 }
25
26 fn get_storage_total_bytes(&self) -> Result<u64, PlatformError> {
28 Err(PlatformError::NotSupported(
29 "get_storage_total_bytes not implemented".to_string(),
30 ))
31 }
32}