1// Copyright 2020 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45//! These type declarations simply exist to reduce the amount of boilerplate in the other parts of
6//! this crate.
78use fatfs::{DefaultTimeProvider, LossyOemCpConverter, ReadWriteSeek};
910pub trait Disk: ReadWriteSeek + Send {
11/// Returns true if the underlying block device for this disk is still present.
12fn is_present(&self) -> bool;
13}
1415// Default implementation, used for tests.
16impl Disk for std::io::Cursor<Vec<u8>> {
17fn is_present(&self) -> bool {
18true
19}
20}
2122impl Disk for block_client::Cache {
23fn is_present(&self) -> bool {
24self.device().is_connected()
25 }
26}
2728pub type FileSystem = fatfs::FileSystem<Box<dyn Disk>, DefaultTimeProvider, LossyOemCpConverter>;
29pub type Dir<'a> = fatfs::Dir<'a, Box<dyn Disk>, DefaultTimeProvider, LossyOemCpConverter>;
30pub type DirEntry<'a> =
31 fatfs::DirEntry<'a, Box<dyn Disk>, DefaultTimeProvider, LossyOemCpConverter>;
32pub type File<'a> = fatfs::File<'a, Box<dyn Disk>, DefaultTimeProvider, LossyOemCpConverter>;