Skip to content

Commit

Permalink
Struct Layer API (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax authored Jun 18, 2024
1 parent b1065a8 commit fa568d4
Show file tree
Hide file tree
Showing 13 changed files with 1,735 additions and 501 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- `libcnb`:
- A new API for working with layers has been added. See the `BuildContext::cached_layer` and `BuildContext::uncached_layer` docs for examples of how to use this API. ([#814](https://github.com/heroku/libcnb.rs/pull/814))

### Changed

- `libcnb`:
- The `Layer` trait and related types and functions have been deprecated. Please migrate to the new API. ([#814](https://github.com/heroku/libcnb.rs/pull/814))
- Errors related to layers have been restructured. While this is technically a breaking change, buildpacks usually don't have to be modified in practice. ([#814](https://github.com/heroku/libcnb.rs/pull/814))

### Fixed

- `libcnb-data`:
Expand Down
4 changes: 4 additions & 0 deletions examples/execd/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// 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;
Expand Down
382 changes: 373 additions & 9 deletions libcnb/src/build.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions libcnb/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::data::launch::ProcessTypeError;
use crate::layer::HandleLayerError;
use crate::layer::LayerError;
use libcnb_common::toml_file::TomlFileError;
use std::fmt::Debug;

Expand All @@ -11,8 +11,8 @@ pub type Result<T, E> = std::result::Result<T, Error<E>>;
/// An error that occurred during buildpack execution.
#[derive(thiserror::Error, Debug)]
pub enum Error<E> {
#[error("HandleLayer error: {0}")]
HandleLayerError(#[from] HandleLayerError),
#[error("Layer error: {0}")]
LayerError(#[from] LayerError),

#[error("Process type error: {0}")]
ProcessTypeError(#[from] ProcessTypeError),
Expand Down
15 changes: 9 additions & 6 deletions libcnb/src/layer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! Provides types and helpers to work with layers.
mod handling;
mod public_interface;
pub(crate) mod shared;
pub(crate) mod struct_api;
pub(crate) mod trait_api;

#[cfg(test)]
mod tests;
pub use shared::DeleteLayerError;
pub use shared::LayerError;
pub use shared::ReadLayerError;
pub use shared::WriteLayerError;

pub(crate) use handling::*;
pub use public_interface::*;
pub use struct_api::*;
pub use trait_api::*;
Loading

0 comments on commit fa568d4

Please sign in to comment.