master
Avril 4 years ago
parent 7070b7c9a8
commit e656f5eec1
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -0,0 +1,17 @@
//! Config parsing error
use super::*;
#[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!()
}
}

@ -0,0 +1,21 @@
//! Global config stuff
use super::*;
/// Global user config
#[derive(Debug)]
pub struct Config
{
/// The directories to find jobs in
pub job_dirs: Vec<PathBuf>,
/// The rules for users
pub user_rules: Vec<UserRule>,
}
impl Default for Config
{
#[inline]
fn default() -> Self
{
Self{job_dirs: Vec::new(), user_rules: Vec::new()}
}
}

@ -1,12 +1,5 @@
//! Job config
use super::*; use super::*;
use std::{
str,
fmt,
path::{
PathBuf,
},
};
/// Target for oneshots /// Target for oneshots
#[derive(Debug,Eq,PartialEq,Hash)] #[derive(Debug,Eq,PartialEq,Hash)]
@ -47,6 +40,8 @@ pub struct Job
what: Command, what: Command,
} }
// Global config
/// Type of access /// Type of access
#[derive(Debug, PartialEq,Eq,Hash)] #[derive(Debug, PartialEq,Eq,Hash)]
pub enum Access pub enum Access
@ -55,37 +50,20 @@ pub enum Access
Deny, Deny,
} }
/// A permission entry for users
#[derive(Debug,PartialEq,Eq,Hash)]
pub enum UserPermAlias {
Single(String),
Group(String),
All,
}
/// Access rule for user /// Access rule for user
#[derive(Debug, PartialEq,Eq,Hash)] #[derive(Debug, PartialEq,Eq,Hash)]
pub struct UserRule pub struct UserRule
{ {
user: String, user: UserPermAlias,
mode: Access, mode: Access,
} }
const DEFAULT_JOB_DIR: &str = "/etc/rori.kron"; 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!()
}
}

@ -0,0 +1,28 @@
use super::*;
use std::{
str,
fmt,
path::{
PathBuf,
Path,
},
};
mod parse;
mod error;
pub use error::*;
mod job;
pub use job::*;
mod global;
pub use global::*;
/// Parse a single config file
#[inline]
pub fn parse_global_single(path: impl AsRef<Path>) -> Result<Config, error::Error>
{
let mut cfg = Config::default();
parse::global(&mut cfg, path)?;
Ok(cfg)
}

@ -0,0 +1,8 @@
//! Parses the config files
use super::*;
/// Parse a single config file
pub fn global(to: &mut Config, path: impl AsRef<Path>) -> Result<(), error::Error>
{
todo!()
}

@ -1,5 +1,4 @@
//! Context that is passed to all workers and children //! Context that is passed to all workers and children
use super::*; use super::*;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};

@ -23,6 +23,6 @@ pub struct Oneesan {
/// Start watching this path for changes of files /// Start watching this path for changes of files
pub fn watch(path: PathBuf) -> Oneesan pub fn watch(path: PathBuf) -> Oneesan
{ {
todo!()
} }

@ -19,8 +19,9 @@ mod log;
mod interval; mod interval;
mod config; mod config;
//mod context; mod live;
//mod live; mod context;
mod job;
async fn do_thing_every() -> Result<(mpsc::Sender<()>, task::JoinHandle<()>), Box<dyn std::error::Error>> async fn do_thing_every() -> Result<(mpsc::Sender<()>, task::JoinHandle<()>), Box<dyn std::error::Error>>
{ {

Loading…
Cancel
Save