You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
1.3 KiB
92 lines
1.3 KiB
use super::*;
|
|
use std::{
|
|
str,
|
|
fmt,
|
|
path::{
|
|
PathBuf,
|
|
},
|
|
};
|
|
|
|
|
|
/// Target for oneshots
|
|
#[derive(Debug,Eq,PartialEq,Hash)]
|
|
pub enum Target
|
|
{
|
|
/// Fired when daemon starts
|
|
Startup,
|
|
/// Fired when config reloaded
|
|
Reload,
|
|
/// Fired only when user tells it to
|
|
Specific,
|
|
}
|
|
|
|
/// When the job should be ran
|
|
#[derive(Debug, PartialEq,Eq,Hash)]
|
|
pub enum When
|
|
{
|
|
/// Run when a target is reached
|
|
Oneshot(Target),
|
|
/// Run on an interval
|
|
Interval(interval::Time),
|
|
}
|
|
|
|
/// A command for `Job`
|
|
#[derive(Debug, Eq,PartialEq,Hash)]
|
|
pub struct Command
|
|
{
|
|
program: String,
|
|
args: Vec<String>,
|
|
}
|
|
|
|
/// Output for `define-job`
|
|
#[derive(Debug, PartialEq,Eq,Hash)]
|
|
pub struct Job
|
|
{
|
|
name: String,
|
|
when: Vec<When>,
|
|
what: Command,
|
|
}
|
|
|
|
/// Type of access
|
|
#[derive(Debug, PartialEq,Eq,Hash)]
|
|
pub enum Access
|
|
{
|
|
Allow,
|
|
Deny,
|
|
}
|
|
|
|
/// Access rule for user
|
|
#[derive(Debug, PartialEq,Eq,Hash)]
|
|
pub struct UserRule
|
|
{
|
|
user: String,
|
|
mode: Access,
|
|
}
|
|
|
|
const DEFAULT_JOB_DIR: &str = "/etc/rori.kron";
|
|
|
|
/// User config
|
|
#[derive(Debug)]
|
|
pub struct Config
|
|
{
|
|
pub job_dirs: Vec<PathBuf>,
|
|
pub user_rules: Vec<UserRule>,
|
|
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
|
|
}
|
|
impl std::error::Error for Error{}
|
|
impl std::fmt::Display for Error
|
|
{
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
|
|
{
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
|
|
|