daipendency_extractor/
library_metadata.rs

1use thiserror::Error;
2
3/// Metadata about a library.
4///
5/// The metadata is typically extracted from a library's manifest file (e.g., `package.json`, `Cargo.toml`).
6#[derive(Debug)]
7pub struct LibraryMetadata<EntryPoint> {
8    /// The name of the library as specified in its manifest
9    pub name: String,
10
11    /// The version of the library, if specified in its manifest
12    pub version: Option<String>,
13
14    /// Documentation string for the library, typically extracted from its manifest or documentation files
15    pub documentation: String,
16
17    /// The entry point(s) for the library.
18    ///
19    /// Whilst this is typically a single path (e.g. Rust's `src/lib.rs`), some languages/frameworks
20    /// may have multiple entry points, such as TypeScript's `exports` directive in `package.json`.
21    pub entry_point: EntryPoint,
22}
23
24#[derive(Error, Debug)]
25pub enum LibraryMetadataError {
26    #[error(transparent)]
27    MissingManifest(#[from] std::io::Error),
28    #[error("{0}")]
29    MalformedManifest(String),
30}