1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::error::*;
use cargo::{
core::{EitherManifest, Manifest, SourceId},
util::toml::read_manifest,
Config,
};
use std::path::Path;
pub fn parse_manifest(manifest_path: &Path) -> Result<Manifest> {
let source_id = SourceId::for_path(manifest_path)?;
let cargo_config = Config::default()?;
let either_manifest = read_manifest(manifest_path, source_id, &cargo_config)
.map_err(|_| Error::FailedToFindManifest(manifest_path.to_owned()))?
.0;
match either_manifest {
EitherManifest::Real(manifest) => Ok(manifest),
_ => Err(Error::FailedToFindManifest(manifest_path.to_owned())),
}
}