Skip to main content

fetch_group_order_is_needed

Function fetch_group_order_is_needed 

Source
pub(crate) const fn fetch_group_order_is_needed(draft: DraftVersion) -> bool
Expand description

Whether a fetch stream on this draft can be read only by an endpoint that knows the Group Order the fetch was asked for.

A statement about the draft, not about the build and not about any one session; whether the draft was compiled at all is draft_is_compiled, asked first by object_framing_bypass because the header decode happens first.

False on drafts 07-17. Drafts 07-14 write each object’s identity outright, and drafts 15, 16 and 17 let an object leave a field off and take the object before it — draft-16 Section 10.4.4.1: “Group ID is the prior Object’s Group ID” — which the reader carries the running state for. Either way an absolute Location comes out of the stream and nothing else, which is all addressing an object needs.

True on drafts 18, 19 and 20, where the Group ID is a difference and the fetch’s Group Order decides its sign. Nothing on the data stream states the order, and the wrong choice decodes as willingly as the right one, so a reader has to be told — see BypassReason::FetchGroupOrderUnknown, where the consequence of the wrong answer is written out.

§Where the answer comes from

One control message settles it. Draft-19 Section 10.12.3: “The publisher responding to a FETCH is responsible for delivering all available Objects in the requested range in the requested order (see Section 10.2.8)”, and draft-19 Section 10.2.8 states what a FETCH that carries no GROUP_ORDER parameter has asked for: “If omitted from FETCH, the receiver uses Ascending (0x1).” So a session that reads the FETCH knows the order for that Request ID, carrying it in a FetchGroupOrders table the framer takes it out of when the response stream opens.

That is why this is a draft fact and the bypass is not. The bypass now belongs to one stream: a fetch stream naming a request this session never saw asked for, which is a publisher answering something nobody requested.

The match is exhaustive on purpose. As a matches! this answered false for a draft nobody had listed, which is the answer that reads a fetch stream without knowing the order — the one reading this function exists to prevent. A fifteenth draft must fail to compile here until someone has read its FETCH section and said which side it is on.