]>
git.proxmox.com Git - rustc.git/blob - vendor/gix-sec/src/trust.rs
4 /// Derive `Full` trust if `path` is owned by the user executing the current process, or `Reduced` trust otherwise.
5 pub fn from_path_ownership(path
: impl AsRef
<std
::path
::Path
>) -> std
::io
::Result
<Self> {
6 Ok(if crate::identity
::is_path_owned_by_current_user(path
.as_ref())?
{
14 /// A trait to help creating default values based on a trust level.
15 pub trait DefaultForLevel
{
16 /// Produce a default value for the given trust `level`.
17 fn default_for_level(level
: Trust
) -> Self;
20 /// Associate instructions for how to deal with various `Trust` levels as they are encountered in the wild.
21 pub struct Mapping
<T
> {
22 /// The value for fully trusted resources.
24 /// The value for resources with reduced trust.
28 impl<T
> Default
for Mapping
<T
>
32 fn default() -> Self {
34 full
: T
::default_for_level(Trust
::Full
),
35 reduced
: T
::default_for_level(Trust
::Reduced
),
41 /// Obtain the value for the given trust `level`.
42 pub fn by_level(&self, level
: Trust
) -> &T
{
44 Trust
::Full
=> &self.full
,
45 Trust
::Reduced
=> &self.reduced
,
49 /// Obtain the value for the given `level` once.
50 pub fn into_value_by_level(self, level
: Trust
) -> T
{
52 Trust
::Full
=> self.full
,
53 Trust
::Reduced
=> self.reduced
,