Expand description
Ergonomic, v5-first Rust types and clients for the TM Forum Open APIs.
rutmf models the TM Forum domain the way you would model it by hand:
typed references, real decimals for money, builders that only accept valid
shapes — with the HTTP clients layered strictly on top, so the data model is
usable on its own.
Unofficial. This crate is a community implementation of the publicly available, Apache-2.0-licensed TM Forum Open API specifications. It is not affiliated with, endorsed by, or certified by TM Forum. “TM Forum” is a trademark of TM Forum.
§The domain model
use rutmf::product::ProductOffering;
let offering = ProductOffering::builder()
.name("Business Internet")
.is_sellable(true)
.build();Creating and updating are different shapes in TMF v5, and this crate keeps them distinct so the compiler catches a malformed request:
use rutmf::core::Timestamp;
use rutmf::product::ProductOfferingCreate;
// `name`, `lifecycle_status` and `last_update` are required on create —
// omitting one is a compile error, not a 400 from the server.
let body = ProductOfferingCreate::builder()
.name("Business Internet")
.lifecycle_status("Active")
.last_update(Timestamp::now())
.build();§Round-trip fidelity
Real TMF payloads carry vendor extensions, and a library that silently drops
them is unusable as integration middleware. Every entity captures unknown
members in Extensions, preserving their relative order:
use rutmf::product::ProductOffering;
let json = r#"{"id":"7655","name":"Basic Firewall","@type":"ProductOffering","x-vendor":{"tier":2}}"#;
let offering: ProductOffering = serde_json::from_str(json).unwrap();
assert_eq!(offering.extensions.get("x-vendor").unwrap()["tier"], 2);
let back = serde_json::to_value(&offering).unwrap();
assert_eq!(back, serde_json::from_str::<serde_json::Value>(json).unwrap());§What is guaranteed, precisely
Decoding then re-encoding any payload is lossless by value:
- every member present in the input with a value is present in the output, with an equal value — including members this crate has no typed field for;
- members within
Extensionskeep their relative order; - no member is invented. A payload that omits the spec-mandatory
@typecomes back without one; ask the type what class it is instead, throughtype_name(). Anything the crate builds declares its class, because a request without@typeis the one a server rejects; - a timestamp keeps the UTC offset it arrived with, so
2020-09-23T16:42:23-04:00does not come back as20:42:23Z— the one re-spelling is+00:00, which RFC 3339 writes asZ.
It is not byte-for-byte. Members this crate knows about are emitted in
struct-declaration order rather than input order; JSON number formatting is
normalised; and a timestamp’s fractional seconds are re-emitted in SI groups,
so .96747 becomes .967470. Compare monetary values as decimals. A
serde_json::Number can retain distinct spellings of the same value.
§The one exception: an explicit null
{"description": null} on a modelled member reads as absence and is not
re-emitted: Option<T> has two states where that needs three, and a
three-state type on every field would cost every caller for a distinction
the v5 schemas make almost nowhere. A null on an unmodelled member lands in
Extensions and does round-trip.
Where the distinction is real — RFC 7386 makes null how a merge patch
removes a member — the …Update types say it:
use rutmf::product::ProductOfferingUpdate;
let update = ProductOfferingUpdate::builder()
.name("Business Internet")
.build()
.deleting("description");
assert!(update.deletes("description"));This is enforced over all 610 vendored TM Forum examples, every one of
them, by tests/conformance.rs.
§Round-tripping is not coverage
An unknown member survives in Extensions whether or not the model
understands it, so a payload round-trips perfectly even if the typed model
misses half of it. tests/coverage.rs is what closes that gap: it reads the
pinned OpenAPI documents and fails if any specified member has no typed
field, if any typed field is absent from the specification, if requiredness
disagrees, or if a member the specification gives a closed vocabulary is
typed as a String rather than an enumeration. It checks 219 Rust types
against 490 v5 schemas. Both suites are needed, and neither substitutes for
the other.
§Feature flags
Domain models are enabled by default and pull in no I/O. Clients are opt-in,
so cargo add rutmf never drags in a TLS stack.
| Feature | Enables |
|---|---|
party, customer, product, order | domain models (default) |
ticket, alarm | the assurance domain: TMF621 tickets, TMF642 alarms |
bill, account, usage | monetisation: TMF678 bills, TMF666 accounts, TMF635 rated usage |
service, resource | the inventory-side models — also on by default, because product needs them for its realizingService and supportingResource references |
api | the transport-agnostic client layer |
transport-reqwest | a ready-made reqwest transport, with OAuth2 and retries |
api-tmf620 | Product Catalog Management (TMF620 v5.0.0) |
api-tmf621 | Trouble Ticket (TMF621 v5.0.1) |
api-tmf642 | Alarm Management (TMF642 v5.0.1) |
api-tmf666 | Account Management (TMF666 v5.0.0) |
api-tmf635 | Product Usage Management (TMF635 v5.0.0) |
api-tmf678 | Customer Bill (TMF678 v5.0.0) |
api-tmf622 | Product Ordering (TMF622 v5.0.0) |
api-tmf629 | Customer Management (TMF629 v5.0.1) |
api-tmf632 | Party Management (TMF632 v5.0.0) |
api-tmf634 | Resource Catalog Management (TMF634 v5.0.0) |
api-tmf637 | Product Inventory (TMF637 v5.0.0) |
api-tmf638 | Service Inventory (TMF638 v5.0.0) |
api-tmf639 | Resource Inventory (TMF639 v5.0.0) |
api-tmf669 | Party Role Management (TMF669 v5.0.0) |
api-tmf679 | Product Offering Qualification (TMF679 v5.0.0) |
server | implement a TMF API: a store trait under a TMF630 handler |
server-axum | an axum Router over that handler |
mock | an in-process TMF server for tests |
schemars | JsonSchema derives on every type |
full | everything above |
Re-exports§
pub use jiff;
Modules§
- account
account - Accounts: who is billed, and how — TMF666.
- alarm
alarm - Fault management: what the network is complaining about — TMF642.
- api
api - HTTP clients for the TM Forum Open APIs.
- bill
bill - Billing: what the customer owes — TMF678.
- core
- Types shared by every TM Forum domain.
- customer
customer - The customer domain.
- mock
mock - An in-process TM Forum server for tests.
- order
order - The ordering domain: product orders and their cancellation.
- party
party - The party domain: individuals and organizations.
- prelude
- The traits whose methods are otherwise invisible.
- product
product - The product domain: what is sold, and what a customer has.
- resource
resource - The resource domain: what the network is made of.
- server
server - Implement a TM Forum API, rather than call one.
- service
service - The service domain: what runs on the network.
- ticket
ticket - The assurance domain: what went wrong, and who is fixing it.
- usage
usage - Usage: what a customer consumed, and what it was rated at — TMF635.
Constants§
- TMF_
VERSION - The TM Forum Open API major version this crate targets.