Skip to main content

draft_is_compiled

Function draft_is_compiled 

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

Whether this build compiled a codec for draft.

DraftVersion carries all thirteen variants under every feature set, so the table is answerable for a draft this binary cannot speak — and that is exactly the case worth getting right. A build that did not compile a draft cannot frame one byte of it, so a table that answers by draft number alone publishes Support::Yes for work the binary cannot do: the documented lie this module exists to prevent.

It is reachable by default, not only under exotic flags: ProxySessionConfig::default().draft is DraftVersion::Draft14, so a --no-default-features --features draft07 binary — a shipped configuration and one of CI’s fourteen rows — is configured for draft 14 unless its caller says otherwise.

§This is also the predicate a session is admitted on

ProxySession::run asks this before it dials and refuses with ProxyError::DraftNotCompiled when the answer is false, so the run that the paragraph below describes no longer happens to anybody. One predicate serves both, which is what keeps the table’s verdict and the session’s admission from becoming two lists that disagree — and the paragraph below stays because it is still the reason the verdict is Support::Unreachable rather than Support::Yes.

§The mechanism, so the verdict is not taken on trust

moqtap-proxy’s draftNN features forward to both moqtap-codec and moqtap-client, so a draft that is off here is off in the codec. AnySubgroupHeader::decode_stream and AnyFetchHeader::decode_stream then fall through to their catch-all arm and return CodecError::UnsupportedDraft(*draft DraftNN not enabled via feature flag*). That is not an incomplete-input error (parser::data::is_incomplete_error admits only UnexpectedEnd), so ObjectFramer’s header poll takes its terminal Err arm, latches BypassReason::DecodeError and forwards the stream uninterpreted. No object on it ever reaches ProxyHook::on_object, which is precisely Support::Unreachable.

§Why cfg! and not #[cfg]

A cfg! per arm keeps the function total. A #[cfg] per arm would make the match non-exhaustive and force a catch-all, and the table would stop being able to answer for the very drafts this exists to answer for.

§The control site reads it too, one decoder later

Site::Control on an uncompiled draft is never invoked either: ControlStreamParser::feed steps over a frame whose AnyControlMessage::decode fails, so the hook is offered nothing. That cell published Support::Yes for a while, because the honest verdict needs instead to name a report and this path emitted none. It emits ImpairmentKind::ControlFrameNotDecodable now, so the cell is Support::Unreachable with Instead::ControlFrameNotDecodable — see classify, step 5.

§What it does not cover

Site::StreamOpen, Site::StreamEnd and Site::Datagram need no codec to fire and are unaffected; Site::StreamHeader fires only behind a decoded header and shares the object site’s fate.