diff --git a/examples/execd/src/layer.rs b/examples/execd/src/layer.rs deleted file mode 100644 index fbf4a124..00000000 --- a/examples/execd/src/layer.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::ExecDBuildpack; -use libcnb::build::BuildContext; -use libcnb::data::layer_content_metadata::LayerTypes; -use libcnb::generic::GenericMetadata; -use libcnb::layer::{Layer, LayerResult, LayerResultBuilder}; -use libcnb::{additional_buildpack_binary_path, Buildpack}; -use std::path::Path; - -pub(crate) struct ExecDLayer; - -impl Layer for ExecDLayer { - type Buildpack = ExecDBuildpack; - type Metadata = GenericMetadata; - - fn types(&self) -> LayerTypes { - LayerTypes { - launch: true, - build: false, - cache: false, - } - } - - fn create( - &mut self, - _context: &BuildContext, - _layer_path: &Path, - ) -> Result, ::Error> { - LayerResultBuilder::new(GenericMetadata::default()) - .exec_d_program( - "dice_roller", - additional_buildpack_binary_path!("dice_roller"), - ) - .build() - } -} diff --git a/examples/execd/src/main.rs b/examples/execd/src/main.rs index 84c2fc42..791e7df3 100644 --- a/examples/execd/src/main.rs +++ b/examples/execd/src/main.rs @@ -1,18 +1,12 @@ -// This example uses the older trait Layer API. The example will be updated to the newer API -// before the next libcnb.rs release. -#![allow(deprecated)] - -mod layer; - -use crate::layer::ExecDLayer; use libcnb::build::{BuildContext, BuildResult, BuildResultBuilder}; use libcnb::data::layer_name; use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder}; use libcnb::generic::{GenericError, GenericMetadata, GenericPlatform}; -use libcnb::{buildpack_main, Buildpack}; +use libcnb::{additional_buildpack_binary_path, buildpack_main, Buildpack}; // Suppress warnings due to the `unused_crate_dependencies` lint not handling integration tests well. use fastrand as _; +use libcnb::layer::UncachedLayerDefinition; #[cfg(test)] use libcnb_test as _; @@ -28,7 +22,19 @@ impl Buildpack for ExecDBuildpack { } fn build(&self, context: BuildContext) -> libcnb::Result { - context.handle_layer(layer_name!("layer_name"), ExecDLayer)?; + let layer_ref = context.uncached_layer( + layer_name!("layer_name"), + UncachedLayerDefinition { + build: false, + launch: true, + }, + )?; + + layer_ref.replace_exec_d_programs([( + "dice_roller", + additional_buildpack_binary_path!("dice_roller"), + )])?; + BuildResultBuilder::new().build() } }