Skip to content

feat: one-way codegen for _return: None (Client::notify) - #4

Merged
Kinflou merged 1 commit into
mainfrom
feat/one-way-codegen
Sep 1, 2026
Merged

feat: one-way codegen for _return: None (Client::notify)#4
Kinflou merged 1 commit into
mainfrom
feat/one-way-codegen

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 1, 2026

Copy link
Copy Markdown
Member

Second of the deferred §4.2 refinements, pairing with runtime#6.

A no-return function (no -> at all) now generates fire-and-forget:

before (#2) now
trait method fn f(&self, …) -> Result<(), FError> fn f(&self, …);
error enum enum FError {} emitted none — a ! on a one-way fn is dropped
dispatcher arm decode → handler → empty ok Envelope decode → handler → write nothing (Server replies with nothing)
client method -> Result<(), CallError<FError>> over Client::call -> Result<(), RuntimeError> over Client::notify

When every function in a protocol is one-way, the dispatch out param is named _out.

_return: Some(KindValue::Unit) (an explicit -> ()) is unchanged — request/response with an empty ack. So KindValue::Unit finally earns its keep: commit() -> () confirms, log(msg) doesn't (§4.4).

Bumps the generated crate's comline-runtime pin to the rev with Client::notify. tests/compiles.rs's poke (already _return: None) now exercises the notify path end to end against comline-runtime; string coverage in tests/generate.rs (6 tests).

Follow-up

Conformance re-bless — the protocol fixture's notify(code: u16) is _return: None, so its golden changes.

A no-return `function` (no `->` at all) now generates fire-and-forget:

- provider trait method is `fn f(&self, args);` — no `Result`, no error
  type (a `!` on a one-way fn is dropped: nowhere to deliver it)
- the dispatcher arm decodes params, runs the handler, writes no
  Envelope; the runtime's Server (comline-runtime#6) then replies with
  nothing
- the client method is `pub fn f(&mut self, args) -> Result<(), RuntimeError>`
  over `Client::notify` — no `CallError<E>`
- no per-function error enum is emitted for it
- when *every* function in a protocol is one-way, the dispatch `out`
  param is named `_out`

`_return: Some(KindValue::Unit)` (an explicit `-> ()`) is unchanged —
request/response with an empty ack. So `KindValue::Unit` finally earns its
keep: `commit() -> ()` confirms, `log(msg)` doesn't (§4.4).

Bumps the generated crate's `comline-runtime` pin to the rev with
`Client::notify`. tests/compiles.rs's `poke` (already `_return: None`)
now exercises the notify path end to end against comline-runtime.
@Kinflou
Kinflou merged commit 1191e76 into main Sep 1, 2026
2 checks passed
@Kinflou
Kinflou deleted the feat/one-way-codegen branch September 2, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant