Skip to main content

Configuration

Struct Configuration 

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

The settings of one generated module.

Every setter returns the configuration, so that a build script can chain them and end with process.

Implementations§

Source§

impl Configuration

Source

pub fn new() -> Self

A configuration with no schema yet, for XSD 1.0, covering every global element.

Source

pub fn schema(&mut self, path: impl AsRef<Path>) -> &mut Self

A schema document to compile, relative to the crate root (the directory of Cargo.toml). Several documents are compiled into one schema set; the documents they include and import are read too. Each document is embedded under this path, or under the location the documents name it by, resolved from here: its key.

A key is relative to the crate root, with / between its parts, however the files are linked or placed; at run time the module’s fallback finds the documents by their keys alone. A document outside the crate root is keyed with .. from the crate root (../shared/common.xsd), so its key spells the directories on the way up, as far as the directory the crate root and the document share: a crate outside the home directory whose schemas are inside it writes the user’s name into the module and the binary. Keep the schemas inside the crate, or link them in, to avoid that.

Source

pub fn module(&mut self, name: impl Into<String>) -> &mut Self

The module’s name: the generator writes $OUT_DIR/<name>.rs, and include_validator!(<name>) declares it. Lower-case ASCII letters, digits and _, starting with a letter or _, not a Rust keyword and not a name Windows reserves for a device (con, nul, com1 …): a file system that ignores case must not see two modules as one file.

Source

pub fn root(&mut self, namespace: &str, local: &str) -> &mut Self

Limit the tables to documents whose root is this global element (namespace is "" for no namespace); may be given several times. Without it, every global element is a possible root. A document with another root is left to the dynamic validator.

Source

pub fn xsd_version(&mut self, version: XsdVersion) -> &mut Self

The XSD version the schema is compiled as (default 1.0). An XSD 1.1 module needs the xsd11 feature on the dependency that includes it; an XSD 1.0 module compiles with or without it.

Source

pub fn map_location(&mut self, from: &str, to: impl AsRef<Path>) -> &mut Self

Read the document at from (an absolute URI as a schema document writes it, such as an http: URL) from the file to, relative to the crate root, which must exist. The document is embedded under from, and a relative location it names is read relative to to and embedded relative to from.

Source

pub fn emit_report(&mut self, on: bool) -> &mut Self

Also write $OUT_DIR/<module>.report: the types, declarations and value checks the tables do not cover, and why (a document that needs one of them is left to the dynamic validator), and the pattern facets without a table. The build prints a warning naming the file.

Source

pub fn process(&self) -> Result<(), Box<dyn Error>>

Compile the schema and write the module, from a build script (it reads CARGO_MANIFEST_DIR and OUT_DIR). A schema that does not compile, a remote location that is not mapped, or a root that is no global element fails with a message that says which.

Trait Implementations§

Source§

impl Clone for Configuration

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Configuration

Source§

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

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

impl Default for Configuration

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.