djal_parser 0.1.0

A library to parse configuration files
Documentation
  • Coverage
  • 100%
    28 out of 28 items documented1 out of 25 items with examples
  • Size
  • Source code size: 24.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.66 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 33s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Djalcoding

A library for parsing .dconfig files

!! This is documentation. 
  !! This is a number
number1: 12.643
  !! This is also a number
number2: -12
  !! This is a color as an rgb string
color1: (0,255,0)
  !! This is a color as an hexadecimal color
color2: #FFFFFF
  !! This is a color represented with a name
color3: red
  !! This is text
text: "Lorem Ipsum"
  !! Those is are booleans
bool1 = yes
bool2 = y
bool2 = true
bool3 = 1 !! Note that this doesn't work for every number, only 1
bool1 = no
bool2 = n
bool2 = false
bool3 = 0

Usage

Retrieving data

Using dparser is quite simple. the library provides you a HashMap wrapper to retrieve the data present associated with a given key inside of the configuration file : ParsedData.

It also allows you to interpret the data as 4 different datatype :

  • bool
  • String
  • f64
  • Color, a struct provided by the library that represents an rgb color and does hexadecimal conversion for you.

Error handling

if the library fails to parse your file, or interpret a datatype, you are provided with two new error types that give you access to the error message, the file where the error happened and (optionally) the line where the error happenned.