use async_trait::async_trait;
use bytes::Bytes;
use lazy_static::lazy_static;
use crate::decoded_image::DecodedImage;
use crate::error::GalileoError;
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait PlatformService {
fn new() -> Self;
async fn load_image_url(&self, url: &str) -> Result<DecodedImage, GalileoError>;
async fn load_bytes_from_url(&self, url: &str) -> Result<bytes::Bytes, GalileoError>;
async fn decode_image(&self, imaage_data: Bytes) -> Result<DecodedImage, GalileoError>;
}
#[cfg(not(target_arch = "wasm32"))]
pub mod native;
#[cfg(not(target_arch = "wasm32"))]
pub type PlatformServiceImpl = native::NativePlatformService;
#[cfg(target_arch = "wasm32")]
pub mod web;
#[cfg(target_arch = "wasm32")]
pub type PlatformServiceImpl = web::WebPlatformService;
lazy_static! {
static ref SERVICE: PlatformServiceImpl = PlatformServiceImpl::new();
}
pub fn instance() -> &'static PlatformServiceImpl {
&SERVICE
}