Skip to main content

Crate scon

Crate scon 

Source
Expand description

§scon-core

scon-core is the Rust implementation of SCON, a strict and deterministic configuration format inspired by HOCON. It provides parsing, sequential substitution resolution, explicit object and array spread, sandboxed file includes, formatting, source analysis, and Serde conversion.

The Cargo package is named scon-core; its Rust library name is scon.

§Installation

[dependencies]
scon-core = "0.1"
serde = { version = "1", features = ["derive"] }

§Example

use serde::Deserialize;

#[derive(Debug, Deserialize, PartialEq)]
struct App {
    name: String,
    port: u16,
}

let app: App = scon::from_str(
    r#"
    name = "demo"
    port = 8080
    "#,
)?;

assert_eq!(app, App { name: "demo".into(), port: 8080 });

Use scon::parse_file or scon::from_file when the document may contain include directives. scon::parse_str and scon::from_str intentionally do not provide filesystem access.

SCON v0.1 uses a single sequential resolution model: substitutions are resolved immediately and forward references are rejected. See the SCON v0.1 specification for the complete grammar and semantics.

§Compatibility

  • Minimum supported Rust version: 1.85
  • License: MIT

Macros§

scon
Construct a Value from a SCON-like literal.

Structs§

AnalyzedDocument
Comment
Definition
Diagnostic
DiagnosticRelatedInformation
Error
FileSourceStore
FormatOptions
IncludeReference
Limits
LineIndex
LoadOptions
ParseOptions
ParsedDocument
Reference
SourcePosition
SourceRange
Symbol
Token
Utf16Position

Enums§

CommentKind
DefinitionKind
DiagnosticSeverity
ErrorCode
Number
ReferenceKind
TokenKind
Value

Constants§

VERSION

Traits§

SourceStore

Functions§

analyze_file
analyze_file_with_store
analyze_source
diagnostic_from_error
format_source
from_file
from_file_with_options
from_str
from_value
get_path
parse_file
parse_file_with_options
parse_source
parse_str
resolve_file
resolve_source
to_string
to_string_fragment
to_string_value
to_value

Type Aliases§

Result