pub struct MiddlewareResult<T> { /* private fields */ }Expand description
What a Middleware returns.
§Examples
use moonlit_pdk::{MiddlewareResult, NoOutput};
let ok = MiddlewareResult::ok(NoOutput {}).with_warning("`force` is deprecated");
assert!(ok.is_success());
assert_eq!(ok.warnings(), ["`force` is deprecated"]);
let failed: MiddlewareResult<NoOutput> = MiddlewareResult::failure("tag already exists");
assert!(!failed.is_success());
assert_eq!(failed.error_message(), Some("tag already exists"));Implementations§
Source§impl<T: Serialize> MiddlewareResult<T>
impl<T: Serialize> MiddlewareResult<T>
Source§impl<T> MiddlewareResult<T>
impl<T> MiddlewareResult<T>
pub fn with_warning(self, msg: impl Into<String>) -> Self
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Whether the middleware succeeded. Useful in sdk::testing unit tests.
Sourcepub fn error_message(&self) -> Option<&str>
pub fn error_message(&self) -> Option<&str>
The failure message, if this result is a failure.
Source§impl<T: Serialize> MiddlewareResult<T>
impl<T: Serialize> MiddlewareResult<T>
Sourcepub fn into_wit(self) -> MiddlewareResult
pub fn into_wit(self) -> MiddlewareResult
Convert to the WIT record. The typed output is serialized to a JSON
object and spread into the (key, json-text) output list (the field
names become the map keys, so steps.NAME.outputs.<field> resolves). A
non-object output or a serialization error degrades to a loud failure.
Auto Trait Implementations§
impl<T> Freeze for MiddlewareResult<T>
impl<T> RefUnwindSafe for MiddlewareResult<T>where
Option<T>: RefUnwindSafe,
impl<T> Send for MiddlewareResult<T>
impl<T> Sync for MiddlewareResult<T>
impl<T> Unpin for MiddlewareResult<T>
impl<T> UnsafeUnpin for MiddlewareResult<T>where
Option<T>: UnsafeUnpin,
impl<T> UnwindSafe for MiddlewareResult<T>where
Option<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more