wasmtime/runtime/vm/mpk/
disabled.rs

1//! Noop implementations of MPK primitives for environments that do not support
2//! the feature.
3
4#[cfg(feature = "pooling-allocator")]
5use crate::prelude::*;
6
7#[cfg(feature = "pooling-allocator")]
8pub fn is_supported() -> bool {
9    false
10}
11
12#[cfg(feature = "pooling-allocator")]
13pub fn keys(_: usize) -> &'static [ProtectionKey] {
14    &[]
15}
16
17#[cfg(any(feature = "async", feature = "pooling-allocator"))]
18pub fn allow(_: ProtectionMask) {}
19
20#[cfg(feature = "async")]
21pub fn current_mask() -> ProtectionMask {
22    ProtectionMask
23}
24
25#[derive(Clone, Copy, Debug)]
26pub enum ProtectionKey {}
27
28impl ProtectionKey {
29    #[cfg(feature = "pooling-allocator")]
30    pub fn protect(&self, _: &mut [u8]) -> Result<()> {
31        match *self {}
32    }
33    #[cfg(feature = "pooling-allocator")]
34    pub fn as_stripe(&self) -> usize {
35        match *self {}
36    }
37}
38
39#[derive(Clone, Copy, Debug)]
40#[cfg(any(feature = "async", feature = "pooling-allocator"))]
41pub struct ProtectionMask;
42
43#[cfg(any(feature = "async", feature = "pooling-allocator"))]
44impl ProtectionMask {
45    #[cfg(any(feature = "async", feature = "pooling-allocator"))]
46    pub fn all() -> Self {
47        Self
48    }
49    #[cfg(feature = "pooling-allocator")]
50    pub fn zero() -> Self {
51        Self
52    }
53    #[cfg(feature = "pooling-allocator")]
54    pub fn or(self, _: ProtectionKey) -> Self {
55        Self
56    }
57}