Skip to main content

Schema

Struct Schema 

Source
pub struct Schema { /* private fields */ }
Expand description

The complete stratum.toml schema.

There is one schema per library version; obtain it with schema. It serialises as {"schema_version": 1, "fields": [...]} for the HTTP schema endpoint, and every other part of this crate (validation, the seed document, the public view) is derived from the same table.

§Examples

use stratum_node_config::schema;

for field in schema().fields() {
    println!("{} ({}): {}", field.path(), field.apply_class(), field.description());
}
assert!(schema().field("listen.address").is_some());

Implementations§

Source§

impl Schema

Source

pub fn version(&self) -> u32

Returns SCHEMA_VERSION.

Source

pub fn fields(&self) -> Fields ⓘ

Iterates over every field in schema order.

Source

pub fn field(&self, path: &str) -> Option<&'static FieldDescriptor>

Looks a field up by its dotted path.

Source§

impl Schema

Source

pub fn seed_text(&self) -> String

Returns the canonical seed stratum.toml: every field at its default, grouped by table in schema order, each preceded by its description and apply class as comments.

The seed always parses, validates, and has exactly the default effective configuration.

§Examples
use stratum_node_config::{schema, ConfigDocument};

let seed = schema().seed_text();
assert!(seed.contains("\n[listen]\n"));
let doc = ConfigDocument::parse(&seed)?;
assert_eq!(doc.config().node_name(), "stratum");

Trait Implementations§

Source§

impl Debug for Schema

Shows the version and the field paths.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Schema

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Forget for Schema

§

impl Freeze for Schema
where &'static [FieldDescriptor]: Freeze,

§

impl Move for Schema

§

impl RefUnwindSafe for Schema

§

impl Send for Schema
where &'static [FieldDescriptor]: Send,

§

impl Sync for Schema

§

impl Unpin for Schema
where &'static [FieldDescriptor]: Unpin,

§

impl UnsafeUnpin for Schema
where &'static [FieldDescriptor]: UnsafeUnpin,

§

impl UnwindSafe for Schema
where &'static [FieldDescriptor]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.