• Stars
    star
    296
  • Rank 140,464 (Top 3 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

INI file parser in Rust

INI in Rust

Build & Test crates.io doc.rs

INI is an informal standard for configuration files for some platforms or software. INI files are simple text files with a basic structure composed of "sections" and "properties".

This is an INI file parser in Rust.

[dependencies]
rust-ini = "0.19"

Usage

  • Create a Ini configuration file.
extern crate ini;
use ini::Ini;

fn main() {
    let mut conf = Ini::new();
    conf.with_section(None::<String>)
        .set("encoding", "utf-8");
    conf.with_section(Some("User"))
        .set("given_name", "Tommy")
        .set("family_name", "Green")
        .set("unicode", "Raspberry树莓");
    conf.with_section(Some("Book"))
        .set("name", "Rust cool");
    conf.write_to_file("conf.ini").unwrap();
}

Then you will get conf.ini

encoding=utf-8

[User]
given_name=Tommy
family_name=Green
unicode=Raspberry\x6811\x8393

[Book]
name=Rust cool
  • Read from file conf.ini
use ini::Ini;

fn main() {
    let conf = Ini::load_from_file("conf.ini").unwrap();

    let section = conf.section(Some("User")).unwrap();
    let tommy = section.get("given_name").unwrap();
    let green = section.get("family_name").unwrap();

    println!("{:?} {:?}", tommy, green);

    // iterating
    for (sec, prop) in &conf {
        println!("Section: {:?}", sec);
        for (key, value) in prop.iter() {
            println!("{:?}:{:?}", key, value);
        }
    }
}
  • More details could be found in examples.

License

The MIT License (MIT)

Copyright (c) 2014 Y. T. CHUNG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

doubanfm-qt

A DoubanFM client
C++
510
star
2

coio-rs

Coroutine I/O for Rust
Rust
456
star
3

mqtt-rs

MQTT protocol library for Rust
Rust
178
star
4

sysuh3c

H3C CLI Client for SYSU, which is implemented in C/C++. With an OpenWRT version.
C++
116
star
5

context-rs

Context utilities in Rust
Assembly
86
star
6

simplesched

The most naive Coroutine scheduler in Rust
Rust
34
star
7

libsodium-ffi

libsodium native binding in Rust
Rust
31
star
8

shadowsocks-yamux-plugin

A shadowsocks SIP003 Plugin with connection multiplexor in YAMUX protocol
Rust
29
star
9

memcached-rs

Memcached library in Rust
Rust
26
star
10

tokio-tfo

TCP Fast Open (TFO) for tokio
Rust
25
star
11

GestureRecognition

Kinect 手势识别。Gesture recognition with Microsoft Kinect. (Bachelor Dissertation Project)
Python
24
star
12

conhash-rs

Consistent Hashing library in Rust
Rust
18
star
13

goxmpp

XMPP Library in Go
Go
15
star
14

coroutine-demo

Coroutine demo for Rust
Rust
15
star
15

HumanWalking

Implement with OpenGL
C++
12
star
16

GBKUnzip

一个用于解压GBK zip的Python脚本
Python
11
star
17

qh3clinet

H3C Client with Qt5, pure C++
C++
10
star
18

sskcp-proxy

A ShadowSocks' KCP Plugin
Rust
7
star
19

qYaH3C

YaH3C with GUI
Python
5
star
20

SYSUEduAdminSystem

Our homework of Software Engineering
JavaScript
4
star
21

SendBySocket

用Socket来发文件
Python
4
star
22

irc-rs

IRC library for Rust
Rust
4
star
23

AndroidGamepadControl

Control a Gamepad on Android
D
3
star
24

asio-poc

Proof of Concept, ASIO for Rust
Rust
3
star
25

HTTPSrv

HTTP Server in C++ 11
C++
3
star
26

FParser

A monadic parser combinators library implementation in F2J (FCore to Java). (Master Dissertation Project)
Python
3
star
27

SYSU_EDAILY

中大E先新闻客户端
Java
2
star
28

sysubbs-apiserver

API Server for SYSUBBS
Python
2
star
29

VariantCpp

Variant Type in C++
C++
2
star
30

Engine3DProject

SYSU Engine3DProject
Java
2
star
31

INeed_Minerva

An android Software developed by SYSU.Minerva
Java
2
star
32

sysuh3c-cgi

CGI for sysuh3c in OpenWRT
C
2
star
33

gYaH3C

YaH3C with GTK+ Frontend and DBus support
Python
1
star
34

sublime-f2j

F2J plugin for Sublime Text
1
star
35

jsonrpc-rs

Yet another implementation of JSON-RPC in Rust
Rust
1
star
36

pomo-server

A pomodoro time management app's server
CSS
1
star
37

HelloWorld

my first github project
1
star
38

argo_android_sdk

SYSU ARGO BBS API
Java
1
star
39

shadowsocks-proxy-plugin

SIP003 Plugin for connecting server via a Proxy
Rust
1
star