Repository navigation
rutis v0.17.0
rutis 0.17.0
0.17.0 converges the public Rust API: a plugin is written one way, what hosts use moved to rutis::host, and a migration tool, rutis-migrate, comes with it. It also adds plugin definitions: a plugin can be handed as a value to a service in another language, which mounts it. TypeScript, Python, Go, Swift and Kotlin plugin code does not change.
Rust API
- One way to write a plugin.
impl Plugin:type Depsnames the dependencies,async fn apply(&self, ctx, deps) -> rutis::Result. NoBoxFuture, lifetimes orEffect; cleanups arectx.effect(|| async move { … }). - One error type,
rutis::Error.?takes any standard error;err.kind()returnsOption<&host::ErrorKind>; an error several parties hold isArc<ErrorKind>. Theanyhowfeature converts to and from anyhow. - Event methods are on
Ctx.ctx.on::<E>,on_sync,listen,emit,parallel,serial,waterfall(e).terminal(t),bail, with closures that need no type annotations. A waterfall'sCall<E>is owned, so it can be stored or moved into another task; each further listener costs what it did in 0.16 (#644). - Layers. The
rutisroot has only the 10 names plugin authors use:Ctx,Plugin,Deps,Event,Disposer,Error,Result,Definition,service,serde. What hosts use is inrutis::host(CtxHost,DynPlugin,Key<T>,ErrorKind, diagnostics); what rutis's own crates share is in the hiddenrutis::internal, with no stability promise. A snapshot locks the public surface, checked by the CI jobpublic-api. - rutis-loader has 11 names at its root and the rest in the modules
runtime,peer,report,editandresolve;Builtins::register("x", P::new)takes the constructor. rutis-sdk isexport_plugin!(id: "x", build: P::new). - The
build.rsservice list is removed (#647, #648):Exports::service/service_inandinclude_exports!are gone. Rust services are exposed only with#[rutis::service]; a type whose source you cannot change is wrapped in a type of your own, which is marked.Exportsonly writes TypeScript declarations, with unchanged output. - The migration tool
rutis-migrate(first release):cargo install rutis-migrate,rutis-migrate 0.17 path/to/crate --write. It rewrites what it can and leaves a// TODO(rutis 0.17): …line where it cannot. See migrating to 0.17.
Plugin definitions
- A plugin can be passed to a service as a value. In Node and Bun, the result of
definePlugin(in Node, Cordis object, function and class plugins too) can be an argument or return value of a service in another language. The receiver gets arutis::Definitionand mounts it withctx.plugin(def.at(&ctx, config)?). Each copy runs in the runtime that handed it over and sees the services where it is mounted. A Rust plugin can make one too, withDefinition::new(ctx, build). - It ends with its source. When the row that handed the definition over (or the Rust plugin that made it) stops, every copy it mounted ends first and its cleanups finish, then the source's own cleanups run;
def.ended()completes then, andatfails after that. A definition mounts only in its source's instance or further inside. - Keeping them is the service's business. How received definitions are kept and chosen is up to the plugin that provides the service, as in Cordis; rutis has no registry for them.
- This release supports Rust, Node and Bun. Python, Go, Swift and Kotlin cannot hand over or receive plugin definitions yet; later releases add them. How to use them: plugin API.
Compatibility
- Only Rust plugins and Rust hosts change code: run
rutis-migratefirst, then fix the rest by migrating to 0.17. Dylib plugins are rebuilt with the new SDK. - Plugin code in the other languages and the
rutis.jsonformat are unchanged. - The protocol adds the capability
plugins(the reference kindplugin), used only when both ends declare it. 0.17.0 and 0.16.0 hosts and runtimes connect as before; they just cannot pass plugin definitions. rutis::Erroris still thrown asCordisErrorin other languages, and the generated TypeScript type is stillCordisErrorThrown.- The guarantee
bridge/exported-servicesis withdrawn with the service list, its rules merged intobridge/marked-services;core/definitions,bridge/plugin-valuesandloader/plugin-value-copiesare new.
Packages
All of these are at 0.17.0: on crates.io rutis, rutis-macros, rutis-bridge, rutis-loader, rutis-host, rutis-sdk, rutis-dylib, rutis-dylib-meta, rutis-dylib-launcher, and rutis-migrate, released for the first time; on npm @arcships/rutis, @arcships/rutis-runtime, @arcships/rutis-bun, @arcships/rutis-host and the five platform packages; on PyPI rutis, rutis-host; the Go module github.com/arcships/rutis/go/rutis (tag go/rutis/v0.17.0); the Swift package (v0.17.0); Kotlin io.github.arcships:rutis and io.github.arcships:rutis-ksp; the rutis-host binaries on the release page.