base/interface/permission/
profile.rs1use super::{Attendance, Basis, Runs};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
8#[non_exhaustive]
9pub enum ExecProfile {
10 #[default]
11 Session,
12 Strict,
14 Unattended,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
20#[non_exhaustive]
21pub struct Obligations {
22 pub scan_nested_repos: bool,
23}
24
25impl Obligations {
26 pub fn scanning_nested_repos(yes: bool) -> Self {
27 Self {
28 scan_nested_repos: yes,
29 }
30 }
31
32 pub fn after(runs: Option<Runs>, profile: ExecProfile) -> Self {
36 Self::scanning_nested_repos(runs.is_some() && profile != ExecProfile::Strict)
37 }
38}
39
40impl ExecProfile {
41 pub fn for_permit(basis: &Basis, runs: Option<Runs>, attendance: Attendance) -> Self {
46 match (basis, runs) {
47 (Basis::Contained | Basis::AcceptEdits, Some(_)) => Self::Strict,
48 (Basis::UnattendedConfined, _) => Self::Unattended,
49 _ if attendance == Attendance::Unattended => Self::Unattended,
50 _ => Self::Session,
51 }
52 }
53}
54
55#[derive(Debug, Clone, PartialEq, Eq)]
57#[non_exhaustive]
58pub struct Approval {
59 pub basis: Basis,
60 pub profile: ExecProfile,
61 pub landing: Option<std::path::PathBuf>,
64}
65
66impl Approval {
67 pub fn new(basis: Basis, profile: ExecProfile) -> Self {
68 Self {
69 basis,
70 profile,
71 landing: None,
72 }
73 }
74
75 pub fn landing_at(mut self, landing: Option<std::path::PathBuf>) -> Self {
76 self.landing = landing;
77 self
78 }
79}