codegraph_parser_api/relationships/
imports.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct ImportRelation {
6 pub importer: String,
8
9 pub imported: String,
11
12 pub symbols: Vec<String>,
14
15 pub is_wildcard: bool,
17
18 pub alias: Option<String>,
20}
21
22impl ImportRelation {
23 pub fn new(importer: impl Into<String>, imported: impl Into<String>) -> Self {
24 Self {
25 importer: importer.into(),
26 imported: imported.into(),
27 symbols: Vec::new(),
28 is_wildcard: false,
29 alias: None,
30 }
31 }
32
33 pub fn with_symbols(mut self, symbols: Vec<String>) -> Self {
34 self.symbols = symbols;
35 self
36 }
37
38 pub fn wildcard(mut self) -> Self {
39 self.is_wildcard = true;
40 self
41 }
42
43 pub fn with_alias(mut self, alias: impl Into<String>) -> Self {
44 self.alias = Some(alias.into());
45 self
46 }
47}