Messages

All 26 UFTP 3.1 message types in uftp: who sends them, constructors with the specification's defaults, replies, typed access and the offer and order builders.

On this page

The 26 types#

BetweenRequestResponse
anyoneTestMessageTestMessageResponse
AGR → CROAGRPortfolioUpdate, AGRPortfolioQuery…Response
DSO → CRODSOPortfolioUpdate, DSOPortfolioQuery…Response
AGR → DSOD-Prognosis, FlexOffer, FlexOfferRevocation, Metering…Response
DSO → AGRFlexRequest, FlexOrder, FlexReservationUpdate, FlexSettlement…Response

Each is a Rust struct, and Message is the enum of all of them. A type can only be sealed by the role that sends it, so seal(&offer, Role::Dso, …) is refused. Request and response are different types.

The simple values are types that cannot hold what the XSD forbids:

  • EntityAddress, InternetDomain, MessageUuid
  • Currency, Amount, ActivationFactor
  • IspSpan, IspDuration
  • TimeZoneName, which is checked against the bundled IANA database

Building one#

Constructors fill in the common case. Every field stays public.

// A conversation starts with its first message's id; .in_conversation(id) continues one.
let meta = Metadata::new(sender, recipient, now, new_id());
// ISPs are PT15M unless .with_isp_duration(…) says otherwise.
let header = FlexHeader::new(meta, zone, day, congestion_point);
// Revision 1, no contract, no service type.
let request = FlexRequest::new(header, expires, vec![
    FlexRequestIsp::requested(IspSpan::new(69, 8)?, -500_000, 0), // 17:00–19:00, 500 kW less
    FlexRequestIsp::available(IspSpan::new(77, 4)?, -100_000, 100_000),
]);

Amount keeps the scale you write. "180.00" goes on the wire as 180.00. This matters for counterparts that require the currency's minor digits; see Interoperability.

Answering one#

Every request has a typed reply, which copies the conversation id and the reference:

let response = request.reply(Reply::accepted(new_id(), now));
let refusal = request.reply(Reply::rejected(new_id(), now, RejectionReason::IspConflict));

Message::reply and Opened::reply do the same without knowing the type. They return None where no generic answer exists:

  • for a response
  • for an accepted TestMessage, whose response has no Result
  • for an accepted AGRPortfolioQuery, whose answer must carry the CRO's data (use its typed reply)

Getting the type you expect#

let request: FlexRequest = opened.into_message().try_into()?;

If the message has another type, the error hands it back with both type names.

From request to offer to order#

The flow helpers copy what the specification requires to be copied:

let offer = request.offer(new_id(), now, expires, Currency::EUR, options);
let order = offer.order(Some("A"), ActivationFactor::FULL, new_id(), now, "ORD-1")?;

Without a preceding message: FlexOffer::unsolicited (a market platform) and FlexOrder::unsolicited (a direct order under the market contract, §3.8.5). The aggregator withdraws an offer with offer.revoke(new_id(), now). Options allow partial activation with OfferOption::new(…).with_min_activation_factor(…).

On the receiving side, check_against compares a message with the one it references:

  • offer.check_against(&request): the parties, period, congestion point, ISP length and zone. It also checks that the request had not expired, and that the offer touches a Requested ISP.
  • order.check_against(&offer): the option, that the ISPs and powers are copied unchanged, the price, the currency, and the minimum activation factor.
  • revocation.check_against(&offer): the parties, and that the offer has not expired.

The flow ends with the month's settlement; see Settling.