Skip to main content

ValidPreparedJobConfig

Struct ValidPreparedJobConfig 

Source
pub struct ValidPreparedJobConfig {
    pub exec: ValidExecutionConfig,
    pub save: ValidSaveAsConfig,
    pub part: ValidTablePartConfig,
    pub item: ValidColumnItemConfig,
    pub cols: ValidTableColumnsConfig,
    pub size: ValidColumnSizeConfig,
    pub date: ValidColumnDateConfig,
    pub time: ValidColumnTimeConfig,
    pub patt: ValidPatternConfig,
    pub work: ValidWorkspaceConfig,
    pub sort: ValidSortByConfig,
}

Fields§

§exec: ValidExecutionConfig§save: ValidSaveAsConfig§part: ValidTablePartConfig§item: ValidColumnItemConfig§cols: ValidTableColumnsConfig§size: ValidColumnSizeConfig§date: ValidColumnDateConfig§time: ValidColumnTimeConfig§patt: ValidPatternConfig§work: ValidWorkspaceConfig§sort: ValidSortByConfig

Implementations§

Source§

impl ValidPreparedJobConfig

Source

pub fn to_toml( &self, _id: &str, _name: Option<&str>, _description: Option<&str>, ) -> String

Generuje plik TOML będący odwrotnością parsowania (eksportuje flagi)

Source

pub fn from_toml(path: Option<&str>) -> Result<Self, String>

Wczytuje konfigurację z pliku TOML. Sztuczka: path: None użyje domyślnej lokalizacji, Some("...") użyje własnej. Główna metoda ładująca. Używa jednej ścieżki docelowej jako źródła prawdy.

Examples found in repository?
examples/try.rs (line 36)
3fn main() {
4	let mode_is_job_from_toml: bool = true;
5	// =========================================================================
6	// ZBIERANIE USTAWIEŃ (Wszystkie dostępne parametry z Valid<NAZWA>Config)
7	// =========================================================================
8	let j: job::ValidPreparedJobConfig = if !mode_is_job_from_toml {
9		//let blank: Vec<&str> = Vec::<&str>::new();
10		//job::ValidPreparedJobConfig {
11		//    // 0. Execution Config (Domyślnie: Debug: true, SaveAs: true, CliColor: true)
12		//    exec: job::ValidExecutionParse::parse_vec_as_config(&blank),
13		//    // 1. Workspace (Domyślnie ".")
14		//    work: job::ValidWorkspaceParse::parse_vec_as_config(["."]),
15		//    // 2. Patterns (Domyślnie zbiór filtrów zdefiniowany w config.rs)
16		//    patt: job::ValidPatternParse::parse_vec_as_config(&blank),
17		//    // 3. Table Parts (Domyślnie md + mf)
18		//    part: job::ValidTablePartParse::parse_vec_as_config(&blank),
19		//    // 4. Column Item (Domyślnie Tree, IconsLite, Name: false, Align: false)
20		//    item: job::ValidColumnItemParse::parse_vec_as_config(["list-tree", "name-show", "ws-show", "icons-lite"]),
21		//    // 5. Table Columns (Domyślnie Date, Time, Size, Item, Path)
22		//    cols: job::ValidTableColumnsParse::parse_vec_as_config(&blank),
23		//    // 6. Column Date (Domyślnie "%Y W%V %u-%a")
24		//    date: job::ValidColumnDateParse::parse_vec_as_config(&blank),
25		//    // 7. Column Time (Domyślnie "%H:%M:%S.%3f")
26		//    time: job::ValidColumnTimeParse::parse_vec_as_config(&blank),
27		//    // 8. Column Size (Domyślnie Decimal / SI)
28		//    size: job::ValidColumnSizeParse::parse_vec_as_config(&blank),
29		//    // 9. Sort By (Domyślnie Name, [Spec][Num][AZaz], Reverse: false)
30		//    sort: job::ValidSortByParse::parse_vec_as_config(&blank),
31		//    // 10. Save As (Domyślnie "./target/.cargo-plot/", "Project Snapshot", SOTC/COTS names)
32		//    save: job::ValidSaveAsParse::parse_vec_as_config(&blank),
33		//}
34		job::ValidPreparedJobConfig::default()
35	} else {
36		job::ValidPreparedJobConfig::from_toml(None).unwrap()
37	};
38
39	// =========================================================================
40	// STEP 0: Inicjalizacja
41	// =========================================================================
42	// =========================================================================
43	// STEP 1: Skanowanie i pobranie metadanych z dysku
44	// =========================================================================
45	let step1 = job::engine_step1_scanner(&j);
46
47	println!("Skanowanie zakończone. Zabrano wierszy (ValidResultMainRow): {}\n", step1.rows.len());
48
49	// =========================================================================
50	// STEP 2: Formatowanie komórek
51	// =========================================================================
52	let step2: Vec<job::FormattedRow> = job::engine_step2_data_formater(&j, &step1);
53
54	// =========================================================================
55	// STEP 6: ZAPISYWANIE
56	// =========================================================================
57	if j.exec.save_as && !j.exec.only_dry {
58		job::engine_step6_data_save(&j, &step2).unwrap();
59	}
60	// =========================================================================
61	// STEP 7: PODGLĄD
62	// =========================================================================
63	if !j.exec.mute {
64		let limit = step2.len().min(75);
65		println!("{}", job::gens::mock_render(&step2[..limit], &j.cols));
66	}
67	// =========================================================================
68	println!("\n=== KONIEC ===\n");
69}
Source

pub fn ensure_config_exists(target_path: &str) -> Result<(), String>

Gwarantuje, że pod wskazaną ścieżką istnieje plik. Jeśli nie – tworzy go z ustawień domyślnych.

Source

pub fn backup_and_reset_config(target_path: &str) -> Result<(), String>

Zmienia nazwę zepsutego pliku na backup (dodając tag czasu) i tworzy na jego miejsce nowy, domyślny.

Trait Implementations§

Source§

impl Clone for ValidPreparedJobConfig

Source§

fn clone(&self) -> ValidPreparedJobConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValidPreparedJobConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValidPreparedJobConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.