Docs.rs
  • java-properties-2.0.0
    • java-properties 2.0.0
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Documentation
    • Repository
    • crates.io
    • Source
    • Owners
    • adamcrume
    • Dependencies
      • encoding_rs ^0.8.32 normal
      • lazy_static ^1.4.0 normal
      • regex ^1.5.5 normal
    • Versions
    • 100% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate java_properties

java_properties2.0.0

  • All Items

Sections

  • Examples

Crate Items

  • Structs
  • Enums
  • Functions

Crates

  • java_properties

Crate java_properties

Source
Expand description

Utilities for reading and writing Java properties files

The specification is taken from https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html. Where the documentation is ambiguous or incomplete, behavior is based on the behavior of java.util.Properties.

§Examples

use java_properties::PropertiesIter;
use java_properties::PropertiesWriter;
use java_properties::read;
use java_properties::write;
use std::collections::HashMap;
use std::env::temp_dir;
use std::fs::File;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::prelude::*;

let mut file_name = temp_dir();
file_name.push("java-properties-test.properties");

// Writing simple
let mut src_map1 = HashMap::new();
src_map1.insert("a".to_string(), "b".to_string());
let mut f = File::create(&file_name)?;
write(BufWriter::new(f), &src_map1)?;

// Writing advanced
let mut src_map2 = HashMap::new();
src_map2.insert("a".to_string(), "b".to_string());
let mut f = File::create(&file_name)?;
let mut writer = PropertiesWriter::new(BufWriter::new(f));
for (k, v) in &src_map2 {
  writer.write(&k, &v)?;
}
writer.finish();

// Reading simple
let mut f2 = File::open(&file_name)?;
let dst_map1 = read(BufReader::new(f2))?;
assert_eq!(src_map1, dst_map1);

// Reading advanced
let mut f = File::open(&file_name)?;
let mut dst_map2 = HashMap::new();
PropertiesIter::new(BufReader::new(f)).read_into(|k, v| {
  dst_map2.insert(k, v);
})?;
assert_eq!(src_map2, dst_map2);

Structs§

Line
A line read from a properties file.
PropertiesError
The error type for reading and writing properties files.
PropertiesIter
Parses a properties file and iterates over its contents.
PropertiesWriter
Writes to a properties file.

Enums§

LineContent
Parsed content of the line.
LineEnding
A line ending style allowed in a Java properties file.

Functions§

read
Reads a properties file into a hash map.
write
Writes a hash map to a properties file.

Results

Settings
Help
    struct
    java_properties::Line
    A line read from a properties file.
    enum
    java_properties::LineEnding
    A line ending style allowed in a Java properties file.
    method
    java_properties::PropertiesError::line_number
    Returns the 1-based line number associated with the error, …
    method
    java_properties::Line::line_number
    Returns the 1-based line number.
    enum
    java_properties::LineContent
    Parsed content of the line.
    method
    java_properties::PropertiesWriter::set_line_ending
    Sets the line ending.
    method
    java_properties::LineContent::from
    Line -> LineContent
    method
    java_properties::Line::consume_content
    Line -> LineContent
    Returns the content of the line, consuming it in the …
    method
    java_properties::Line::clone
    &Line -> Line
    method
    java_properties::Line::line_number
    &Line -> usize
    Returns the 1-based line number.
    method
    java_properties::Line::content
    &Line -> &LineContent
    Returns the content of the line.
    method
    java_properties::Line::eq
    &Line, &Line -> bool
    method
    java_properties::Line::cmp
    &Line, &Line -> Ordering
    method
    java_properties::Line::fmt
    &Line, &mut Formatter -> Result
    method
    java_properties::Line::partial_cmp
    &Line, &Line -> Option<Ordering>
    method
    java_properties::Line::hash
    &Line, &mut __H -> ()
    method
    java_properties::Line::clone
    &Line -> Line