Trait ResultLiquidReplaceExt

Source
pub trait ResultLiquidReplaceExt<T> {
    // Required methods
    fn lossy_chain<S: Into<Cow<'static, str>>>(self, msg: S) -> Result<T>;
    fn lossy_chain_with<F>(self, msg: F) -> Result<T>
       where F: FnOnce() -> Cow<'static, str>;
    fn replace<S: Into<Cow<'static, str>>>(self, msg: S) -> Result<T>;
    fn replace_with<F>(self, msg: F) -> Result<T>
       where F: FnOnce() -> Cow<'static, str>;
}
Expand description

Result extension methods for adapting third party errors to Error.

Required Methods§

Source

fn lossy_chain<S: Into<Cow<'static, str>>>(self, msg: S) -> Result<T>

Create an Error ignoring E as the cause.

§Example
use std::io;
use liquid_error::Result;
use liquid_error::ResultLiquidReplaceExt;

let error = Err(io::Error::new(io::ErrorKind::NotFound, "Oops"));
let error: Result<i32> = error.lossy_chain("Missing liquid partial");
Source

fn lossy_chain_with<F>(self, msg: F) -> Result<T>
where F: FnOnce() -> Cow<'static, str>,

Create an Error ignoring E as the cause.

§Example
use std::io;
use liquid_error::Result;
use liquid_error::ResultLiquidReplaceExt;

let filename = "foo";
let error = Err(io::Error::new(io::ErrorKind::NotFound, "Oops"));
let error: Result<i32> = error
    .lossy_chain_with(|| format!("Missing liquid partial: {}", filename).into());
Source

fn replace<S: Into<Cow<'static, str>>>(self, msg: S) -> Result<T>

Create an Error ignoring E as the cause.

§Example
use std::io;
use liquid_error::Result;
use liquid_error::ResultLiquidReplaceExt;

let error = Err(io::Error::new(io::ErrorKind::NotFound, "Oops"));
let error: Result<i32> = error.replace("Missing liquid partial");
Source

fn replace_with<F>(self, msg: F) -> Result<T>
where F: FnOnce() -> Cow<'static, str>,

Create an Error ignoring E as the cause.

§Example
use std::io;
use liquid_error::Result;
use liquid_error::ResultLiquidReplaceExt;

let filename = "foo";
let error = Err(io::Error::new(io::ErrorKind::NotFound, "Oops"));
let error: Result<i32> = error
    .replace_with(|| format!("Missing liquid partial: {}", filename).into());

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T, E> ResultLiquidReplaceExt<T> for Result<T, E>
where E: Error + Send + Sync + 'static,

Source§

fn lossy_chain<S: Into<Cow<'static, str>>>(self, msg: S) -> Result<T>

Source§

fn lossy_chain_with<F>(self, msg: F) -> Result<T>
where F: FnOnce() -> Cow<'static, str>,

Source§

fn replace<S: Into<Cow<'static, str>>>(self, msg: S) -> Result<T>

Source§

fn replace_with<F>(self, msg: F) -> Result<T>
where F: FnOnce() -> Cow<'static, str>,

Implementors§