Trait common_failures::io::IoContextErrorExt [] [src]

pub trait IoContextErrorExt<T, E>: Sized {
    fn io_context<Tgt>(
        self,
        operation: Operation,
        target: Tgt
    ) -> Result<T, Context<IoError>>
    where
        Tgt: Into<Target>
; fn io_read_context<Tgt>(self, target: Tgt) -> Result<T, Context<IoError>>
    where
        Tgt: Into<Target>
, { ... }
fn io_write_context<Tgt>(self, target: Tgt) -> Result<T, Context<IoError>>
    where
        Tgt: Into<Target>
, { ... } }

This is an unfortunate duplicate of IoContextExt that we require because Rust doesn't allow allow us to implement IoContextExt for both E: Fail and failure::Error, at least not from outside the failure crate.

Required Methods

Specify the "context" within which an I/O operation occurred. Will be used to generate a human-readable error message if needed.

use common_failures::prelude::*;
use common_failures::io::{Operation, Target};
use std::fs::create_dir_all;
use std::path::Path;

fn create_directory(path: &Path) -> Result<()> {
    create_dir_all(path).io_context(
        Operation::Create,
        Target::Directory(path.to_owned()),
    )?;
    Ok(())
}

Provided Methods

Specify the "context" within which an I/O read operation occurred. Will be used to generate a human-readable error message if needed.

use common_failures::prelude::*;
use std::fs::File;
use std::path::Path;

fn open_example(path: &Path) -> Result<File> {
    Ok(File::open(path).io_read_context(path)?)
}

Specify the "context" within which an I/O write operation occurred. Will be used to generate a human-readable error message if needed.

Implementations on Foreign Types

impl<T> IoContextErrorExt<T, Error> for Result<T, Error>
[src]

[src]

[src]

[src]

Implementors