block_protocol/
lib.rs

1// Copyright 2024 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.
4
5use bitflags::bitflags;
6
7mod fifo;
8
9pub use fifo::*;
10
11bitflags! {
12    /// Options that may be used for writes.
13    #[repr(transparent)]
14    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
15    pub struct WriteFlags: u32 {
16        const FORCE_ACCESS = 1;
17        const PRE_BARRIER = 2;
18    }
19}
20
21#[repr(C)]
22#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
23pub struct WriteOptions {
24    pub inline_crypto: InlineCryptoOptions,
25    pub flags: WriteFlags,
26}
27
28#[repr(C)]
29#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
30pub struct ReadOptions {
31    pub inline_crypto: InlineCryptoOptions,
32}
33
34#[repr(C)]
35#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
36pub struct InlineCryptoOptions {
37    pub is_enabled: bool,
38    pub slot: u8,
39    pub dun: u32,
40}
41
42impl InlineCryptoOptions {
43    pub fn enabled(slot: u8, dun: u32) -> Self {
44        Self { is_enabled: true, slot, dun }
45    }
46}