libcnb.rs

libcnb.rs is a Rust language binding of the Cloud Native Buildpacks spec. It is a non-opinionated implementation adding language constructs and convenience methods for working with the spec. It values strong adherence to the spec and data formats.
Usage
Here's a quick start template that can be cloned.
View the examples for some buildpack samples.
All spec data files are implemented in the libcnb::data module.
libcnb::platform::Platform represents the /platform directory in the CNB spec.
Example Buildpack
A basic hello world buildpack looks like:
Detect
For /bin/detect, libcnb::detect::cnb_runtime_detect handles processing the arguments (made available through libcnb::detect::DetectContext and handling the lifecycle of the detect script (including exiting with libcnb::detect::DetectOutcome). This function will exit and write the build plan where applicable. The buildpack author is responsible for writing the FnOnce(DetectContext<P>) -> Result<DetectOutcome, E> where E: std::fmt::Display that libcnb::detect::cnb_runtime_detect] takes.
use ;
use messages;
Build
For /bin/build, libcnb::build::cnb_runtime_build will handle processing the arguments and exiting. Arguments and layer creation can be found on libcnb::build::BuildContext. If an error is raised, libcnb::build::cnb_runtime_build will print out an error message and exit with an error status code. The buildpack author is responsible for defining a Fn(BuildContext<P>) -> Result<(), E> where E: std::fmt::Display, P: libcnb::platform::Platform.
use GenericBuildContext;
use HashMap;
Installation
Add the following to your Cargo.toml file:
[]
= "0.1.0"
Compiler support requires rustc 1.31+ for 2018 edition