#![warn(missing_docs)]
mod annotated;
mod bundle;
mod canonical;
mod catalog;
mod error;
mod model;
mod pattern;
mod ron_adapter;
mod runtime;
mod source_message;
mod value;
pub use annotated::AnnotatedLocalizedString;
pub use bundle::{
Bundle, BundleEntry, BundleRow, BundleTerm, BundleTermForm, BundleTermSurface, Diagnostic,
DiagnosticCode, ExpansionDescriptor, IsolationPolicy, Localizer, NumberFormat, PluralRules,
ResolveOutcome, ResolvedLocalizedPart, ResolvedLocalizedPartsOutcome, TextDirection,
};
pub use catalog::SourceCatalog;
pub use error::{DeserializeError, ResolveError, SerializeError, TroxValueError};
pub use model::{
Argument, ArgumentKind, ArgumentSchema, IdentityDescriptor, NumericBranch, NumericBranchKey,
Pattern, PluralCategory, SelectIdentityBranch, SelectorKey, SelectorRecord, TermArgument,
TermId, TroxInteger, TroxNumber, Version, expansion_row_id, identity_ids, revision_id,
};
pub fn contract_signature(
identity: &IdentityDescriptor,
arguments: &std::collections::BTreeMap<String, ArgumentSchema>,
) -> Result<String, TroxValueError> {
value::contract_signature(identity, arguments)
.map_err(|error| TroxValueError::new("trox.contract", error.to_string()))
}
pub use pattern::{
PatternValue, SelectArm, TroxSelector, counted, exact, few, indefinite, ls, many, meaning, one,
opaque, ordinal, other, otherwise, plural, select, term, two, tx, tx_owned, txa, when, zero,
};
pub use ron_adapter::{RonPlaceholder, RonTx};
pub use source_message::{SourceMessage, SourceMessageRef};
pub use value::LocalizedString;
pub mod prelude {
pub use crate::{
AnnotatedLocalizedString, LocalizedString, Localizer, ResolvedLocalizedPart, TermId,
TroxSelector, counted, exact, few, indefinite, ls, many, meaning, one, opaque, ordinal,
other, otherwise, plural, select, term, two, tx, tx_args, txa, when, zero,
};
}
#[macro_export]
macro_rules! tx_args {
() => {{
::std::collections::BTreeMap::<::std::string::String, $crate::Argument>::new()
}};
($($name:ident $(=> $value:expr)?),+ $(,)?) => {{
let mut args = ::std::collections::BTreeMap::<
::std::string::String,
$crate::Argument,
>::new();
$(
$crate::tx_args!(@insert args, $name $(=> $value)?);
)+
args
}};
(@insert $args:ident, $name:ident) => {{
let value = &$name;
let argument = $crate::Argument::from_borrowed(value);
if $args.insert(::std::string::String::from(stringify!($name)), argument).is_some() {
panic!("TROX_ASSERT duplicate argument `{}`", stringify!($name));
}
}};
(@insert $args:ident, $name:ident => $value:expr) => {{
let evaluated_once = $value;
let argument = $crate::Argument::from_borrowed(&evaluated_once);
if $args.insert(::std::string::String::from(stringify!($name)), argument).is_some() {
panic!("TROX_ASSERT duplicate argument `{}`", stringify!($name));
}
}};
}