Crate pipelight_files

Source
Expand description

§File - parse file types with pretty diagnostics.

Well structured parsing error reports with the language specific error types. thanks to the thiserror and miette crate.

Let say you want to deserialize to a Config struct.



let res = serde_yaml::from_str::<Value>(&string);
match res {
    Ok(res) => {
        // do things
    },
    Err(e) => {
        let err = YamlError::new(e, &string);
        return Err(err.into());
    }
};


let res = toml::from_str::<Value>(&string);
match res {
    Ok(res) => {
        // do things
    },
    Err(e) => {
        let err = TomlError::new(e, &string);
        return Err(err.into());
    }
};

Structs§

FileTypeIter
An iterator over the variants of FileType
HclError
A Hcl report type with hint, colors and code span. For better configuration file debugging
JsonError
A JSON report type with hint, colors and code span. For better configuration file debugging
TomlError
A TOML report type with hint, colors and code span. For better configuration file debugging
YamlError
A YAML report type with hint, colors and code span. For better configuration file debugging

Enums§

CastError
FileType
An enum representing the file extention accepted/recognized by pipelight

Functions§

is_absolute
Determine whether the provided path struct is an absolute path
is_filename
Determine whether the provided path struct is a filename
is_relative
Determine whether the provided path struct is a relative pathReturn false if the path is a filename like “my_file” and isn’t prefixed with “./”.Return true if the file path is “./my_file”.This is a tweaked strict version of the standard Path::is_relative() method.
read_last_line
Read the last line of the file at the provide path and return it as a string.