Crate aisil

Crate aisil 

Source
Expand description

A lightweight framework to define APIs as types.

The core functionality of this crate is to define APIs as types bound by traits. Based on these definitions it is possible to reason about an API from different perspectives: derive, type check and much more.

  • A method is defined as Request → (method name, Response) dependency in the context of an API (See HasMethod).

  • An API is defined as ApiMetaType[*] dependency (See IsApi), where [*] is a heterogeneous list of request types that belong to the API.

You can define these traits manually, but you should use define_api macro instead.

The extra functionality of this crate is to provide some tools to build implementors of APIs and some basic middleware/combinators for those implementors.

  • An implementor is a type that implements an API via ImplsMethod. The ImplsMethod trait is somewhat similar to tower::Service and other similar traits.

It is possible to use only the core functionality of this crate in combination with any “service trait”. But since tower is quite old and low-level and there’s no established industry standard alternatives, this crate uses ImplsMethod to define that extra functionality.

Modules§

clientclient
Utilities for calling an API as a client.
combinator
A few built-in API and implementor combinators.
generate
Utilities to generate specifications, IDLs, SDKs, etc.
server
Utilities for exposing an API implementor as a server.

Macros§

define_api
Main macro to define APIs in aisil format.

Structs§

BoxedImpl
Wrapper for implementors of ImplsMethodBoxed

Traits§

CallApi
Helper trait to allow pretty type applications that ImplsMethod does not allow. You may need it when one request belongs to two APIs and a backend implements both of them. You should not reuse requests in different APIs but in case you do, this would be helpful.
HasMethod
Type dependency from RequestResponse in the context of an API
ImplsMethod
Generalization over an asyncronous function bound by an API definition. Similar to tower::Service but associated types are defined in the API definition instead of the trait itself.
ImplsMethodBoxed
Same as ImplsMethod but dyn-compatible
IsApi
API definition as a type. Use define_api macro to define this impl.