starnix_core/mm/
mlock.rs

1// Copyright 2025 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
5#[derive(Clone, Debug, Default)]
6pub enum MlockPinFlavor {
7    #[default]
8    Noop,
9    ShadowProcess,
10    VmarAlwaysNeed,
11}
12
13impl MlockPinFlavor {
14    pub fn parse(s: &str) -> Result<Self, anyhow::Error> {
15        Ok(match s {
16            "noop" => Self::Noop,
17            "shadow_process" => Self::ShadowProcess,
18            "vmar_always_need" => Self::VmarAlwaysNeed,
19            _ => anyhow::bail!(
20                "unknown mlock_flavor {s}, known flavors: noop, shadow_process, vmar_always_need"
21            ),
22        })
23    }
24}