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::*;
10pub const SENTINEL_SLOT_VALUE: u8 = fifo::_SENTINEL_SLOT_VALUE as u8;
11
12bitflags! {
13    /// Options that may be used for writes.
14    #[repr(transparent)]
15    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
16    pub struct WriteFlags: u32 {
17        const FORCE_ACCESS = 1;
18        const PRE_BARRIER = 2;
19    }
20}
21
22#[repr(C)]
23#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
24pub struct WriteOptions {
25    pub flags: WriteFlags,
26    pub inline_crypto_options: InlineCryptoOptions,
27}
28
29#[repr(C)]
30#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
31pub struct ReadOptions {
32    pub inline_crypto_options: InlineCryptoOptions,
33}
34
35#[repr(C)]
36#[derive(Clone, Copy, Debug, PartialEq, Eq)]
37/// InlineCryptoOptions only used if `slot` is not equal to its sentinel value (0xff).
38pub struct InlineCryptoOptions {
39    pub dun: u32,
40    pub slot: u8,
41}
42
43impl Default for InlineCryptoOptions {
44    fn default() -> Self {
45        InlineCryptoOptions { dun: 0, slot: SENTINEL_SLOT_VALUE }
46    }
47}