stylex_structures/
named_import_source.rs1use serde::Deserialize;
2
3#[derive(Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
4pub struct NamedImportSource {
5 pub r#as: String,
6 pub from: String,
7}
8
9#[derive(Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
10pub enum ImportSources {
11 Regular(String),
12 Named(NamedImportSource),
13}
14
15impl ImportSources {
16 pub fn is_named_export(&self) -> bool {
17 match self {
18 ImportSources::Regular(_) => false,
19 ImportSources::Named(_named) => true,
20 }
21 }
22
23 pub fn get_import_str(&self) -> &str {
24 match self {
25 ImportSources::Regular(regular) => regular,
26 ImportSources::Named(named) => named.r#as.as_str(),
27 }
28 }
29}
30
31#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
32pub enum RuntimeInjection {
33 Boolean(bool),
34 Regular(String),
35 Named(NamedImportSource),
36}
37
38impl RuntimeInjection {
39 pub fn is_named_export(&self) -> bool {
40 match self {
41 RuntimeInjection::Boolean(_) => false,
42 RuntimeInjection::Regular(_) => false,
43 RuntimeInjection::Named(_named) => true,
44 }
45 }
46
47 pub fn is_regular_export(&self) -> bool {
48 match self {
49 RuntimeInjection::Boolean(_) => false,
50 RuntimeInjection::Regular(_) => true,
51 RuntimeInjection::Named(_) => false,
52 }
53 }
54
55 pub fn is_boolean_export(&self) -> bool {
56 match self {
57 RuntimeInjection::Boolean(_) => true,
58 RuntimeInjection::Regular(_) => false,
59 RuntimeInjection::Named(_) => false,
60 }
61 }
62
63 pub fn as_boolean(&self) -> Option<&bool> {
64 match self {
65 RuntimeInjection::Boolean(value) => Some(value),
66 RuntimeInjection::Regular(_) => None,
67 RuntimeInjection::Named(_named) => None,
68 }
69 }
70 pub fn as_regular(&self) -> Option<&String> {
71 match self {
72 RuntimeInjection::Boolean(_) => None,
73 RuntimeInjection::Regular(value) => Some(value),
74 RuntimeInjection::Named(_) => None,
75 }
76 }
77 pub fn as_named(&self) -> Option<&NamedImportSource> {
78 match self {
79 RuntimeInjection::Boolean(_) => None,
80 RuntimeInjection::Regular(_) => None,
81 RuntimeInjection::Named(value) => Some(value),
82 }
83 }
84}
85
86#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
87pub enum RuntimeInjectionState {
88 Boolean(bool),
89 Regular(String),
90 Named(NamedImportSource),
91}