Module

std::serializer::writer

Serializer Writer

Shared writer configuration used by concrete format frontends.

Overview

This module provides scalar Serializer::write overloads for primitive Ignis values. The overloads append text to an existing output string using the selected writer’s escaping and field-key policy.

Scalar Output Rules

Value kind Output behavior
boolean Writes true or false
integers/floats Writes toString() output without quotes
char Writes a quoted, escaped one-byte character
str / String Writes a quoted, escaped string

Scalar overloads do not inspect supportsScalarRoot; root-shape validation is the responsibility of concrete front-ends such as Toml::writeRoot.

Common Contract For Serializer::write

Every overload follows the same contract:

  • append to output; never clear existing content
  • use writer only for formatting policy that affects this value kind
  • return Result::OK(true) when text was appended successfully
  • return Serializer::Error only for format rules that can be violated

Numeric and boolean overloads cannot currently fail because they only append toString() output. String and character overloads also currently cannot fail because escaping is total for byte-backed UTF-8 strings.

Usage Pattern

Concrete front-ends call these overloads after selecting a writer:

import Json from "std::json";
import Serializer from "std::serializer";

let writer: Serializer::Writer = Json::writer();
let mut output: String = String::new();
Serializer::write(&mut output, 42, &writer)!;
namespace Serializer

Scalar writer overloads for serializer-backed formats.

These overloads append primitive values to a caller-owned String using the punctuation and root-shape policy provided by Serializer::Writer.

Functions

function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;
function write(output: &mut String, value: &String, _writer: &Writer): Result<boolean, Error>

Writes an owned string reference as a quoted string scalar.

Quotes, backslashes, common control characters, and other ASCII control bytes are escaped by Serializer::writeQuotedString. Returns Result::OK(true) after writing the quoted string.

Example

let writer: Serializer::Writer = Json::writer();
let value: String = String::create("line\nquoted");
let mut output: String = String::new();
Serializer::write(&mut output, &value, &writer)!;