pub struct AppServices {
pub dir: PathBuf,
pub settings: SettingsStore,
pub recent_files: RecentFiles,
pub crashes: CrashDiagnostics,
}Expand description
应用级服务集合。目录由应用给出;框架只负责 load/save,不自动选择用户目录。
Fields§
§dir: PathBuf§settings: SettingsStore§recent_files: RecentFiles§crashes: CrashDiagnosticsImplementations§
Source§impl AppServices
impl AppServices
pub fn new(dir: impl Into<PathBuf>) -> Self
pub fn settings_path(&self) -> PathBuf
pub fn recent_files_path(&self) -> PathBuf
pub fn crashes_path(&self) -> PathBuf
Sourcepub fn load_with_report(&mut self) -> Result<LoadReport>
pub fn load_with_report(&mut self) -> Result<LoadReport>
0.8 入口:加载并返回每个文件的确定性结果(含损坏回退标记)。
IO 不可用时该字段记为 IoUnavailable,不误报为损坏。
Sourcepub fn save(&mut self) -> Result<()>
pub fn save(&mut self) -> Result<()>
保持 0.7 签名的保存入口:写纯文本 + schema sidecar,不强制 owner。
多窗口场景应改用 save_with_owner 以避免并发覆盖。
Sourcepub fn save_with_owner(&mut self, owner: &OwnerLease) -> Result<()>
pub fn save_with_owner(&mut self, owner: &OwnerLease) -> Result<()>
0.8 入口:写入前校验 owner 租约仍有效,防止丢租约后的旧窗口覆盖新数据。
pub fn schema_state(&self) -> SchemaState
pub fn try_acquire_owner(&self) -> Result<OwnerLease, AcquireError>
Sourcepub fn heal_after_recovery(&mut self, report: &LoadReport) -> Result<()>
pub fn heal_after_recovery(&mut self, report: &LoadReport) -> Result<()>
损坏文件恢复后回写主文件,让下一轮读取不再走备份路径。
Trait Implementations§
Source§impl Clone for AppServices
impl Clone for AppServices
Auto Trait Implementations§
impl Forget for AppServices
impl Freeze for AppServiceswhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<(String, String)>: Freeze,
PhantomData<PathBuf>: Freeze,
PhantomData<CrashRecord>: Freeze,
impl Move for AppServices
impl RefUnwindSafe for AppServices
impl Send for AppServices
impl Sync for AppServices
impl Unpin for AppServices
impl UnsafeUnpin for AppServiceswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
PhantomData<PathBuf>: UnsafeUnpin,
PhantomData<CrashRecord>: UnsafeUnpin,
impl UnwindSafe for AppServices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more