pub fn parse_cargo_toml(
content: &str,
doc_uri: &Uri,
) -> Result<ParseResult, CargoError>Expand description
Parses a Cargo.toml file and extracts all dependencies with positions.
§Errors
Returns an error if:
- TOML syntax is invalid
- File path cannot be converted from URL
§Examples
use deps_cargo::parse_cargo_toml;
use tower_lsp_server::ls_types::Uri;
let toml = r#"
[dependencies]
serde = "1.0"
tokio = { version = "1.0", features = ["full"] }
"#;
let url = Uri::from_file_path("/test/Cargo.toml").unwrap();
let result = parse_cargo_toml(toml, &url).unwrap();
assert_eq!(result.dependencies.len(), 2);