uftp
UFTP 3.1, the USEF Flex Trading Protocol, in Rust. Distribution system operators (DSOs) and aggregators use UFTP to trade grid flexibility: a DSO asks for less consumption at a congestion point, an aggregator offers it, the DSO orders it and settles it. Since version 3, UFTP is maintained by LF Energy as Shapeshifter.
Documentation · API reference · Getting started
Not the UDP multicast file-transfer tool of the same name.
Status: 0.2, early. Before 1.0 a minor version may change the API; the changelog says how.
Highlights
- All 26 messages of UFTP 3.1.0, with their XML, CS1 (Ed25519) signatures, and the rules of §3.5 and the use cases, under the specification's own rejection reasons.
- A receiver that answers correctly. A bad document gets an HTTP status. A valid message that breaks a rule gets 200 and a signed Rejected response, sent only to the verified sender.
- The whole trade, settlement included. Flow helpers build each message from the one
before, and
check_againstchecks it against what it answers; a settlement item by item. - One receive call.
Endpoint::receiveverifies before it parses, then checks the rules, the market, the clock, the outbox and replays, in that order. - Checked against the reference. In CI, LF Energy's Java library verifies and re-signs every type uftp writes, and its validators judge 51 rule cases next to uftp. The differences are its own bugs, each listed in the documentation.
- Sans I/O. No clock, randomness, files or network: you bring them. With the
httpfeature it maps onto thehttp1.x types (axum, hyper, reqwest, ureq) without a runtime. - DST-correct ISPs, refusals that are safe to log, fuzzed decoding and mutation-tested rules. Rust 1.88 or later.
Example
use *;
// The DSO asks for 500 kW less consumption tomorrow, 17:00–19:00 (ISPs 69–76).
let meta = new;
let header = new;
let isps = vec!;
let request = new;
let document = seal?.to_xml; // what it POSTs
// The aggregator's endpoint.
let mut endpoint = new
.with_market;
match endpoint.receive
Runnable examples:
cargo run --example flex_request: one request, signed, opened and answered.cargo run --example loopback: a whole trade (request, offer, order, settlement checked by the aggregator) with a replayed order.
Development
The justfile mirrors CI:
License
Licensed under either of Apache License, Version 2.0 or
MIT license at your option. The XSDs under xsd/ are the Shapeshifter
project's, Apache-2.0 (see xsd/NOTICE), and are used by the tests only.