Skip to main content

PathErrorExt

Trait PathErrorExt 

Source
pub trait PathErrorExt<T> {
    // Required method
    fn with_path(self, path: impl Into<PathBuf>) -> Result<T, SsgError>;
}
Expand description

Context extension trait for mapping std::io::Error contexts with path info.

§Examples

use ssg::{PathErrorExt, SsgError};
use std::io;

let res: io::Result<()> = Err(io::Error::other("denied"));
let mapped = res.with_path("restricted.txt");
assert!(matches!(mapped, Err(SsgError::Io { .. })));

Required Methods§

Source

fn with_path(self, path: impl Into<PathBuf>) -> Result<T, SsgError>

Converts a std::io::Result into an SsgError mapping the path context.

§Examples
use ssg::{PathErrorExt, SsgError};
use std::io;

let ok: io::Result<u32> = Ok(7);
assert_eq!(ok.with_path("any").unwrap(), 7);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> PathErrorExt<T> for Result<T>

Source§

fn with_path(self, path: impl Into<PathBuf>) -> Result<T, SsgError>

Implementors§