Upgrade snafu to 0.7.x
This commit is contained in:
parent
17d0e3df7e
commit
6af4c9140c
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -189,6 +189,12 @@ version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
@ -514,9 +520,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "snafu"
|
||||
version = "0.6.10"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7"
|
||||
checksum = "a152ba99b054b22972ee794cf04e5ef572da1229e33b65f3c57abbff0525a454"
|
||||
dependencies = [
|
||||
"doc-comment",
|
||||
"snafu-derive",
|
||||
@ -524,10 +530,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "snafu-derive"
|
||||
version = "0.6.10"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b"
|
||||
checksum = "d5e79cdebbabaebb06a9bdbaedc7f159b410461f63611d4d0e3fb0fab8fed850"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
@ -38,7 +38,7 @@ rayon = "1.5.3"
|
||||
regex = "1.6.0"
|
||||
serde_yaml = "0.9.14"
|
||||
slug = "0.1.4"
|
||||
snafu = "0.6.10"
|
||||
snafu = "0.7.3"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.3.0"
|
||||
|
16
src/lib.rs
16
src/lib.rs
@ -391,7 +391,7 @@ impl<'a> Exporter<'a> {
|
||||
true => self.parse_and_export_obsidian_note(src, dest),
|
||||
false => copy_file(src, dest),
|
||||
}
|
||||
.context(FileExportError { path: src })
|
||||
.context(FileExportSnafu { path: src })
|
||||
}
|
||||
|
||||
fn parse_and_export_obsidian_note(&self, src: &Path, dest: &Path) -> Result<()> {
|
||||
@ -416,15 +416,15 @@ impl<'a> Exporter<'a> {
|
||||
};
|
||||
if write_frontmatter {
|
||||
let mut frontmatter_str = frontmatter_to_str(context.frontmatter)
|
||||
.context(FrontMatterEncodeError { path: src })?;
|
||||
.context(FrontMatterEncodeSnafu { path: src })?;
|
||||
frontmatter_str.push('\n');
|
||||
outfile
|
||||
.write_all(frontmatter_str.as_bytes())
|
||||
.context(WriteError { path: &dest })?;
|
||||
.context(WriteSnafu { path: &dest })?;
|
||||
}
|
||||
outfile
|
||||
.write_all(render_mdevents_to_mdtext(markdown_events).as_bytes())
|
||||
.context(WriteError { path: &dest })?;
|
||||
.context(WriteSnafu { path: &dest })?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -438,11 +438,11 @@ impl<'a> Exporter<'a> {
|
||||
file_tree: context.file_tree(),
|
||||
});
|
||||
}
|
||||
let content = fs::read_to_string(&path).context(ReadError { path })?;
|
||||
let content = fs::read_to_string(&path).context(ReadSnafu { path })?;
|
||||
let (frontmatter, content) =
|
||||
matter::matter(&content).unwrap_or(("".to_string(), content.to_string()));
|
||||
let frontmatter =
|
||||
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeError { path })?;
|
||||
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?;
|
||||
|
||||
let mut parser_options = Options::empty();
|
||||
parser_options.insert(Options::ENABLE_TABLES);
|
||||
@ -746,7 +746,7 @@ fn create_file(dest: &Path) -> Result<File> {
|
||||
}
|
||||
File::create(&dest)
|
||||
})
|
||||
.context(WriteError { path: dest })?;
|
||||
.context(WriteSnafu { path: dest })?;
|
||||
Ok(file)
|
||||
}
|
||||
|
||||
@ -759,7 +759,7 @@ fn copy_file(src: &Path, dest: &Path) -> Result<()> {
|
||||
}
|
||||
std::fs::copy(&src, &dest)
|
||||
})
|
||||
.context(WriteError { path: dest })?;
|
||||
.context(WriteSnafu { path: dest })?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{ExportError, WalkDirError};
|
||||
use crate::{ExportError, WalkDirSnafu};
|
||||
use ignore::{DirEntry, Walk, WalkBuilder};
|
||||
use snafu::ResultExt;
|
||||
use std::fmt;
|
||||
@ -88,9 +88,9 @@ pub fn vault_contents(path: &Path, opts: WalkOptions) -> Result<Vec<PathBuf>> {
|
||||
let mut contents = Vec::new();
|
||||
let walker = opts.build_walker(path);
|
||||
for entry in walker {
|
||||
let entry = entry.context(WalkDirError { path })?;
|
||||
let entry = entry.context(WalkDirSnafu { path })?;
|
||||
let path = entry.path();
|
||||
let metadata = entry.metadata().context(WalkDirError { path })?;
|
||||
let metadata = entry.metadata().context(WalkDirSnafu { path })?;
|
||||
|
||||
if metadata.is_dir() {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user