PR004: implement asset status-first lifecycle surface
This commit is contained in:
@@ -37,6 +37,24 @@ pub enum LoadStatus {
|
||||
COMMITTED,
|
||||
CANCELED,
|
||||
ERROR,
|
||||
UnknownHandle,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(i32)]
|
||||
pub enum AssetLoadError {
|
||||
AssetNotFound = 1,
|
||||
SlotKindMismatch = 2,
|
||||
SlotIndexInvalid = 3,
|
||||
BackendError = 4,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(i32)]
|
||||
pub enum AssetOpStatus {
|
||||
Ok = 0,
|
||||
UnknownHandle = 1,
|
||||
InvalidState = 2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::asset::{
|
||||
AssetEntry, BankStats, BankType, HandleId, LoadStatus, PreloadEntry, SlotRef, SlotStats,
|
||||
AssetEntry, AssetLoadError, AssetOpStatus, BankStats, BankType, HandleId, LoadStatus,
|
||||
PreloadEntry, SlotRef, SlotStats,
|
||||
};
|
||||
|
||||
pub trait AssetBridge {
|
||||
@@ -9,10 +10,10 @@ pub trait AssetBridge {
|
||||
preload: Vec<PreloadEntry>,
|
||||
assets_data: Vec<u8>,
|
||||
);
|
||||
fn load(&self, asset_name: &str, slot: SlotRef) -> Result<HandleId, String>;
|
||||
fn load(&self, asset_name: &str, slot: SlotRef) -> Result<HandleId, AssetLoadError>;
|
||||
fn status(&self, handle: HandleId) -> LoadStatus;
|
||||
fn commit(&self, handle: HandleId);
|
||||
fn cancel(&self, handle: HandleId);
|
||||
fn commit(&self, handle: HandleId) -> AssetOpStatus;
|
||||
fn cancel(&self, handle: HandleId) -> AssetOpStatus;
|
||||
fn apply_commits(&self);
|
||||
fn bank_info(&self, kind: BankType) -> BankStats;
|
||||
fn slot_info(&self, slot: SlotRef) -> SlotStats;
|
||||
|
||||
@@ -8,7 +8,7 @@ pub(crate) const ENTRIES: &[SyscallRegistryEntry] = &[
|
||||
"load",
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
caps::ASSET,
|
||||
Determinism::NonDeterministic,
|
||||
false,
|
||||
@@ -32,7 +32,7 @@ pub(crate) const ENTRIES: &[SyscallRegistryEntry] = &[
|
||||
"commit",
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
caps::ASSET,
|
||||
Determinism::NonDeterministic,
|
||||
false,
|
||||
@@ -44,7 +44,7 @@ pub(crate) const ENTRIES: &[SyscallRegistryEntry] = &[
|
||||
"cancel",
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
caps::ASSET,
|
||||
Determinism::NonDeterministic,
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user