Skip to main content

Crate ccf_app

Crate ccf_app 

Source
Expand description

Experimental Rust API for native CCF applications.

A registration function installs endpoint handlers on a Registry, and export_app! exports it to CCF. Each handler call receives a ReadOnlyContext or WriteContext, which gives access to the request, the response and raw-byte KV maps in the call’s transaction. See samples/apps/basic_rust in the CCF repository for a complete application.

Handlers may run concurrently, and may be re-executed after a transaction conflict (see RetrySafeHandler). KV writes are applied only if the response status is 2xx. A handler returns an EndpointError to send an error response, and ? on a BridgeResult sends HTTP 500. Panics are caught and also sent as HTTP 500, which requires panic = "unwind".

Macros§

export_app
Export register, a fn(&mut Registry) -> BridgeResult<()>, as the application’s entry point.

Structs§

EndpointError
Error response returned by a handler.
Map
Read-write access to a raw-byte KV map, from WriteContext::map.
ReadOnlyContext
Request, response and read-only KV access for one call of a Registry::read_only handler.
ReadOnlyMap
Read-only access to a raw-byte KV map, from ReadOnlyContext::map.
Registry
Endpoint registry, passed to the function exported with export_app!.
WriteContext
Request, response and read-write KV access for one call of a Registry::read_write handler.

Enums§

Auth
Authentication policy for an endpoint.
BridgeError
Failure of an SDK call into CCF.

Traits§

Codec
Optional conversion between application values and KV bytes.
RetrySafeHandler
Marker trait for endpoint handlers, which CCF may re-execute.

Type Aliases§

BridgeResult
Result of an SDK call into CCF.
EndpointResult
Result of a handler: Ok keeps the response set by the handler, and Err replaces it with an error response.