diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
commit | 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch) | |
tree | bdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/gix-sec/src/lib.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff) | |
download | rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip |
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-sec/src/lib.rs')
-rw-r--r-- | vendor/gix-sec/src/lib.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/gix-sec/src/lib.rs b/vendor/gix-sec/src/lib.rs new file mode 100644 index 000000000..2f35d98cf --- /dev/null +++ b/vendor/gix-sec/src/lib.rs @@ -0,0 +1,60 @@ +//! A shared trust model for `gitoxide` crates. +//! +//! ## Feature Flags +#![cfg_attr( + feature = "document-features", + cfg_attr(doc, doc = ::document_features::document_features!()) +)] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +// `unsafe_code` not forbidden because we need to interact with the libc +#![deny(missing_docs, rust_2018_idioms, unsafe_code)] + +use std::fmt::{Display, Formatter}; + +/// A way to specify how 'safe' we feel about a resource, typically about a git repository. +#[derive(Copy, Clone, Ord, PartialOrd, PartialEq, Eq, Debug, Hash)] +#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +pub enum Trust { + /// Caution is warranted when using the resource. + Reduced, + /// We have no doubts that this resource means no harm and it can be used at will. + Full, +} + +/// +pub mod trust; + +/// Allow, deny or forbid using a resource or performing an action. +#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)] +#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] +pub enum Permission { + /// Fail outright when trying to load a resource or performing an action. + Forbid, + /// Ignore resources or try to avoid performing an operation. + Deny, + /// Allow loading a resource or performing an action. + Allow, +} + +/// +pub mod permission; + +bitflags::bitflags! { + /// Whether something can be read or written. + #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] + pub struct ReadWrite: u8 { + /// The item can be read. + const READ = 1 << 0; + /// The item can be written + const WRITE = 1 << 1; + } +} + +impl Display for ReadWrite { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + std::fmt::Debug::fmt(self, f) + } +} + +/// Various types to identify entities. +pub mod identity; |