blob: 33452d8e764c0920f72f6a68993a99573f12862c [file] [log] [blame]
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::errors::*;
#[derive(Debug, Copy, Clone)]
pub struct BlockDeviceGeometry {
pub block_size: usize,
pub block_count: usize,
}
pub trait BlockDevice {
fn geom(&self) -> BlockDeviceGeometry;
fn read_block(&self, block: usize, block: &mut [u8]) -> Result<(), BFSErr>;
fn write_block(&mut self, block: usize, block: &[u8]) -> Result<(), BFSErr>;
fn erase_block(&mut self, block: usize) -> Result<(), BFSErr>;
fn read_range(&self, addr: usize, data: &mut [u8]) -> Result<(), BFSErr>;
fn write_range(&mut self, addr: usize, data: &[u8]) -> Result<(), BFSErr>;
fn overwrite_range(&mut self, addr: usize, data: &[u8]) -> Result<(), BFSErr>;
}