Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.

CollectionWriter

Ivan Semenkov edited this page Feb 5, 2021 · 1 revision

Table of contents

About

It is writer for collection (array, list) option.

pub struct CollectionWriter

write_int32

Add new integer value to current collection.

pub fn write_int32(&self, value : i32) -> Option<CollectionWriter>
Example
use librustconfig::config::Config;

let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_array("int32_collection") {
  Some(s) => { 
    s.write_int32(321); 
    s.write_int32(-12);
  },
  None => { /* ... */ }
}

write_int64

Add new int64 value to current collection.

pub fn write_int64(&self, value : i64) -> Option<CollectionWriter>
Example
use librustconfig::config::Config;

let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_array("int64_collection") {
  Some(s) => { 
    s.write_int64(321000); 
  },
  None => { /* ... */ }
}

write_float64

Add new float value to current collection.

pub fn write_float64(&self, value : f64) -> Option<CollectionWriter>
Example
use librustconfig::config::Config;

let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_array("float_collection") {
  Some(s) => { 
    s.write_float64(321.001); 
  },
  None => { /* ... */ }
}

write_bool

Add new boolean value to current collection.

pub fn write_bool(&self, value : bool) -> Option<CollectionWriter>
Example
use librustconfig::config::Config;

let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_array("bool_collection") {
  Some(s) => { 
    s.write_bool(false); 
  },
  None => { /* ... */ }
}

write_string

Add new string value to current collection.

pub fn write_string<S>(&self, value : S) -> Option<CollectionWriter>
  where S: Into<String>
Example
use librustconfig::config::Config;

let cfg = Config::new();
let group = cfg.create_section("group").unwrap();
match group.create_array("str_collection") {
  Some(s) => { 
    s.write_string("test string"); 
  },
  None => { /* ... */ }
}
Clone this wiki locally