Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add with_default to OperatorBuilder #3738

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions core/src/types/operator/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,21 @@ pub struct OperatorBuilder<A: Accessor> {
}

impl<A: Accessor> OperatorBuilder<A> {
/// Create a new operator builder.
/// Create a new operator builder with default layers.
#[allow(clippy::new_ret_no_self)]
pub fn new(accessor: A) -> OperatorBuilder<impl Accessor> {
// Make sure error context layer has been attached.
OperatorBuilder { accessor }
.layer(ErrorContextLayer)
.layer(CompleteLayer)
Self::with_default(Self::empty(accessor))
}

/// Return an empty [OperatorBuilder].
pub fn empty(accessor: A) -> Self {
Self { accessor }
}

/// Add default layers to builder.
pub fn with_default(builder: OperatorBuilder<impl Accessor>) -> OperatorBuilder<impl Accessor> {
builder.layer(ErrorContextLayer).layer(CompleteLayer)
}

/// Create a new layer with static dispatch.
Expand Down
Loading