Repository navigation
Conversation
Both take a subset of the protocols their side provides, blocking or async: `Services::new().with_chat(..)` adds one, `Absent` in a field leaves one out, and the all-provided struct literal is what it was. accept / connect build the `comline@2` Hello at runtime from what was given plus the protocols this side calls (every protocol of the other side), through `Hello::build`, instead of embedding the package's whole Hello. - The package module emits `HEADER` and one `P_<path>` entry per protocol (from generation's `hello_parts`) in place of the `HELLO` bytes; `handshake` takes the entries provided and called. - A dispatcher's `provide_on`, and `Services::provide_on`, return the runtime's `Result` (a protocol the handshake didn't accept is `Unavailable`), and accept / connect propagate it. - Pins: generation 99187d7, runtime e736221 (also the generated code's `RUNTIME_REV`). `connections_subset` goldens, FEATURES and features.json blessed. wire_invariants rebuilds the whole-connection Hello from the header and entries, so its pinned bytes are unchanged. Closes #133
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #133
ServicesandClientServicesnow take a subset of the protocols their side provides, blocking andasync = true.accept/connectbuild thecomline@2Hello at runtime from what was given plus the protocols this side calls (every protocol of the other side, the default in the Decided section), instead of embedding the package's whole Hello.API shape
Why this and not
Optionfields or a plain builder:Optionfields make the all-provided case longer (chat: Some(ChatImpl)), andNonecan't be inferred:Services<A, B>is generic over each implementation, so every omitted field needs a turbofish. That fails "as short to write as today".Vecof boxed registrations) would change the all-provided literal and type-erase the dispatchers.ProvideConformanceChat) with two impls, one for anything that implements the protocol's trait and one forAbsent. Coherence holds because both the trait andAbsentare local to the generated crate. Existing code that writes the literal compiles untouched.Services::new()isServices<Absent, ..>and eachwith_<field>swaps one type parameter, so the type of a partly built value is exact and a wrong implementation is still a compile error naming the protocol's trait. The trait carries the protocol's Hello entry as a const (Absenthas none), so what is listed is decided by the types, with no runtime flags.with_prefixes the setters so a protocol namedNeworEntriescan't collide withnew/entries.handshake(provided, called).Generated code
HEADER(c2::HelloHeader) and oneP_<PATH>(c2::ProtocolEntry) per protocol, from generation'shello_parts; function numbers only.HELLOand the zero-argumenthandshake()are gone.handshake(provided, called)isComline2Handshake::new(params, Hello::build(&HEADER, provided, called)).acceptbuilds it fromservices.entries()and the client's protocols;connectfrom its own services and the server's. A protocol in both lists (@provider = Multiple) is listed once byHello::build.Servicesonly has the protocols the accepting side provides,ClientServicesthe dialling side's. The runtime checks the rest (check_provide).provide_on(the dispatchers', andServices::provide_on) returnResult<(), RuntimeError>andaccept/connectpropagate it. Undercomline@2a protocol the handshake didn't accept isUnavailable. Withcomline@1/none/ JSON-RPC a subset means fewer dispatchers and nothing else (the proposal's note).Pins
generation
99187d7, runtimee736221(rev =lines only, plusRUNTIME_REV, the rev the generated code's manifests name). Onecomline-core(69039e7) across generation, the runtime's dev-dependency and this repo, checked withcargo metadata.xtask --checkshows no drift instd-extra/.Goldens
Blessed with
CONFORMANCE_BLESS=1. Existing goldens change in three ways only, all consequences of the runtime bump or of this feature:comline-runtimerev in the// ... add it to your Cargo.tomlcomment (bounds,connections_async).provide_onreturnsResult<(), RuntimeError>(+ a doc paragraph saying when it fails).connection.rs:Absent, the per-protocol slot trait,Services/ClientServiceswithnew/with_*/entries, a doc bullet on subsets,?onprovide_on; forcomline@2alsoHELLO/handshake()replaced byHEADER/P_*/handshake(provided, called).New:
connections_subset(code and lib).FEATURES.md/features.json: the fixture is listed as proof for protocols, connections, nested namespaces,datagram@3,comline@2andpacked@1; no feature changes state.wire_invariants.txtis unchanged for every existing fixture: the test now rebuilds the whole connection's Hello fromHEADERand theP_*entries and prints the sameHELLO = ...bytes it pinned before (the file only gains theconnections_subsetsections). Other test updates:entry_points/compiles(rustdoc) list the new hidden items, andcompilesgains behaviour tests for the subset, sync and async: a protocol left out is refused by the peer (Unavailable,UnknownProtocol) in both directions, a side providing nothing, and the literal with all and withAbsent.No
#[ignore], ledger entries or waivers.Open questions
accept/connect. With the default Hello (everything called) it only happens when the peer is a different version that refuses a protocol underscope = protocol(provide->Unavailable), where before the connection came up with that protocol disabled. That is the runtime#126 behaviour as decided; flagging that it reaches generatedaccept/connectas an error.Services(e.g..calls(&[..])), or a parameter ofaccept/connect?