rustxform-core 0.2.1

Core data model (Survey, Question, Settings) for rustxform.
Documentation
  • Coverage
  • 100%
    108 out of 108 items documented0 out of 23 items with examples
  • Size
  • Source code size: 19.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 869.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • horacioskrp/rustxform
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • horacioskrp

rustxform-core

Core data model shared across the rustxform pipeline — the normalized, backend-agnostic representation of an XLSForm after reading and parsing, and before XForm emission.

            ┌────────┐   ┌───────┐   ┌───────┐
 XLSForm ──▶│ reader │──▶│ parse │──▶│ xform │──▶ XForm XML
            └────────┘   └───────┘   └───────┘
               Workbook  ▸▸ Survey ◂◂   (reads the model)
                            core: the types every stage speaks

rustxform-core has no dependencies and defines no behavior beyond a couple of lookup helpers: it is purely the vocabulary the other crates exchange.

What it contains

Type Role
Survey A whole parsed form: settings, a children node tree, choices, languages, entity, audit, external_instances, osm_tags.
Node A tree node: Question, Group(Container) or Repeat(Container).
Question A leaf field: kind, name, label/hint, logic columns, parameters, media, default, …
Container A group or repeat: name, label, appearance, repeat count, children.
Kind Resolved type semantics: Builtin, Select, Osm, or Unknown.
Builtin / Control / SelectType The XForm mapping of a built-in type, its body control, and the selection flavor (One/Multiple/Rank).
Preload / Action Metadata preloads (jr:preload) and model actions (odk:recordaudio, odk:setgeopoint).
Choice / ChoiceList Choice options and named lists.
Localized / Media Single- or multi-language text, and label media attachments.
Entity An Entities declaration (create/update a dataset row).
Settings Form-level settings (form_id, title, version, …).

Example

use rustxform_core::{resolve_builtin, Control};

// `resolve_builtin` maps an XLSForm type token to its XForm binding.
let integer = resolve_builtin("integer").unwrap();
assert_eq!(integer.bind_type, "int");
assert_eq!(integer.control, Some(Control::Input));

let note = resolve_builtin("note").unwrap();
assert!(note.readonly);

// `select_*`, `osm` and unrecognized tokens return `None` — they are resolved
// by the parser, which has the choice lists and tag sets in context.
assert!(resolve_builtin("select_one").is_none());

Every type derives Debug, Clone and PartialEq, so forms are easy to build by hand in tests and to compare.

Note

This is an internal building block of the rustxform workspace. To compile XLSForms, depend on the top-level rustxform crate instead; reach for rustxform-core only when you build other tools on the same model.

License

Licensed under either of Apache-2.0 or MIT at your option.