workspacer_toml/
get_package_section_fields.rs1crate::ix!();
3
4impl GetPackageAuthors for CargoToml {
5 type Error = CargoTomlError;
6
7 fn get_package_authors(&self) -> Result<Option<Vec<String>>, Self::Error> {
8 debug!("Attempting to retrieve `authors` from CargoToml directly.");
9 if let Some(pkg) = self.content().as_table().and_then(|t| t.get("package")) {
12 if let Some(pkg_table) = pkg.as_table() {
13 if let Some(auth_arr) = pkg_table.get("authors").and_then(|v| v.as_array()) {
15 let mut result = Vec::new();
16 for author_val in auth_arr {
17 if let Some(author_str) = author_val.as_str() {
18 result.push(author_str.to_string());
19 }
20 }
21 trace!("Found authors array in CargoToml: {:?}", result);
22 return Ok(Some(result));
23 }
24 }
25 }
26 debug!("No authors field found in CargoToml.");
28 Ok(None)
29 }
30}
31
32impl GetRustEdition for CargoToml {
33 type Error = CargoTomlError;
34
35 fn get_rust_edition(&self) -> Result<Option<String>, Self::Error> {
36 debug!("Attempting to retrieve `edition` from CargoToml directly.");
37 if let Some(pkg) = self.content().as_table().and_then(|t| t.get("package")) {
39 if let Some(pkg_table) = pkg.as_table() {
40 if let Some(edition_val) = pkg_table.get("edition").and_then(|v| v.as_str()) {
41 trace!("Found edition='{}' in CargoToml.", edition_val);
42 return Ok(Some(edition_val.to_string()));
43 }
44 }
45 }
46 debug!("No edition field found in CargoToml.");
47 Ok(None)
48 }
49}
50
51impl GetLicenseType for CargoToml {
52 type Error = CargoTomlError;
53
54 fn get_license_type(&self) -> Result<Option<String>, Self::Error> {
55 debug!("Attempting to retrieve `license` from CargoToml directly.");
56 if let Some(pkg) = self.content().as_table().and_then(|t| t.get("package")) {
58 if let Some(pkg_table) = pkg.as_table() {
59 if let Some(lic_val) = pkg_table.get("license").and_then(|v| v.as_str()) {
60 trace!("Found license='{}' in CargoToml.", lic_val);
61 return Ok(Some(lic_val.to_string()));
62 }
63 }
64 }
65 debug!("No license field found in CargoToml.");
66 Ok(None)
67 }
68}
69
70impl GetCrateRepositoryLocation for CargoToml {
71 type Error = CargoTomlError;
72
73 fn get_crate_repository_location(&self) -> Result<Option<String>, Self::Error> {
74 debug!("Attempting to retrieve `repository` from CargoToml directly.");
75 if let Some(pkg) = self.content().as_table().and_then(|t| t.get("package")) {
77 if let Some(pkg_table) = pkg.as_table() {
78 if let Some(repo_val) = pkg_table.get("repository").and_then(|v| v.as_str()) {
79 trace!("Found repository='{}' in CargoToml.", repo_val);
80 return Ok(Some(repo_val.to_string()));
81 }
82 }
83 }
84 debug!("No repository field found in CargoToml.");
85 Ok(None)
86 }
87}