Expand description
Proc macros for the myelin crate.
This crate is an implementation detail: always invoke its macros via the
myelin re-exports (e.g. #[myelin::service]). See the
service attribute below for the full input/output contract.
§Worked example
ⓘ
use myelin::service;
#[service(api_id = 0x0001)]
pub trait GreeterService {
async fn greet(&self, name: String) -> String;
fn health(&self) -> bool; // sync — dispatched without `.await`
}expands (roughly) to:
GreeterRequest/GreeterResponseenums (serde-gated#[derive]s)GreeterService(async, preserved verbatim) +GreeterServiceSync(sync mirror —asyncstripped from every method)GreeterClient<T>+GreeterClientSync<T, B>with one client method per trait methodgreeter_dispatch/greeter_dispatch_syncandgreeter_serve/greeter_serve_syncGreeterTokioService/GreeterEmbassyService<M, N>/GreeterEmbassyClientTransport<'a, M, N>type aliases (feature-gated in the consuming crate)greeter_embassy_service!macro_rules!(embassy-gated) for static instantiation, with nested*_client!/*_server!/*_client_sync!helpersGREETER_API_ID: u16 = 0x0001(or an FNV-1a hash of the trait ident when theapi_idargument is omitted)
Multiple services can be multiplexed onto a single transport with
[myelin::compose_service!].
Methods may be either async fn or plain fn; in the generated async
dispatch, sync methods are called directly (no spurious .await).
Cross-service clients always expose async method stubs regardless of
whether the underlying trait method was sync, because the transport is
always async.
Attribute Macros§
- service
- Generate channel-API plumbing from a trait definition.