Expand description
#[derive(FromXbrl)] for xbrlkit.
Binds the fields of a struct to XBRL concepts. The binding lives in
#[xbrl(..)] attributes and nowhere else, so the struct’s serde names stay
its Rust names — which is what reaches JSON, Arrow and Parquet.
Depend on xbrlkit and use the derive it re-exports; this crate is not
meant to be used on its own, and the code it generates refers to
::xbrlkit.
ⓘ
use xbrlkit::FromXbrl;
#[derive(Default, FromXbrl)]
#[xbrl(instant)]
pub struct BalanceSheet {
/// The date the figures are as of.
#[xbrl(period_end)]
pub as_of: Option<String>,
#[xbrl(concept = "us-gaap:Assets")]
pub assets: Option<f64>,
/// The first concept the filing reports wins.
#[xbrl(concept = "us-gaap:Liabilities", alias = "us-gaap:LiabilitiesNoncurrent")]
pub liabilities: Option<f64>,
}§Field attributes
| Attribute | The field is |
|---|---|
concept = ".." [, alias = ".."]… | read from these concepts, in order of preference |
nested | another FromXbrl struct, read in the same scope |
each_period | a Vec of a FromXbrl struct, one per reported period |
period_start / period_end | the dates of the period the struct was read for |
| (none) | left at its Default |
What a concept field holds is decided by its type — see
xbrlkit::bind::FromFacts.
§Struct attributes
#[xbrl(instant)] or #[xbrl(duration)] says which kind of period the
struct’s concepts are reported for, so that each_period does not produce
a balance sheet for a quarter or an income statement for a date.
Derive Macros§
- From
Xbrl - Derives
xbrlkit::FromXbrlfor a struct with named fields. See the crate docs.