parse_assets match case in rust
This commit is contained in:
1
backend/Cargo.lock
generated
1
backend/Cargo.lock
generated
@@ -14913,6 +14913,7 @@ dependencies = [
|
||||
"url",
|
||||
"uuid",
|
||||
"windmill-macros",
|
||||
"windmill-parser",
|
||||
"windmill-parser-py",
|
||||
"windmill-parser-sql",
|
||||
"windmill-parser-ts",
|
||||
|
||||
@@ -75,6 +75,7 @@ windmill-macros.workspace = true
|
||||
windmill-parser-sql.workspace = true
|
||||
windmill-parser-ts.workspace = true
|
||||
windmill-parser-py.workspace = true
|
||||
windmill-parser.workspace = true
|
||||
jsonwebtoken.workspace = true
|
||||
backon.workspace = true
|
||||
openidconnect = { workspace = true, optional = true }
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use windmill_parser::asset_parser::ParseAssetsResult;
|
||||
|
||||
use crate::scripts::ScriptLang;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone, Hash, Eq, sqlx::Type)]
|
||||
#[sqlx(type_name = "ASSET_KIND", rename_all = "lowercase")]
|
||||
@@ -35,3 +38,19 @@ pub struct AssetUsage {
|
||||
pub kind: AssetUsageKind,
|
||||
pub access_type: AssetUsageAccessType,
|
||||
}
|
||||
|
||||
pub fn parse_assets<'a>(
|
||||
input: &'a str,
|
||||
lang: ScriptLang,
|
||||
paths_storage: &'a mut Vec<String>,
|
||||
) -> anyhow::Result<Option<Vec<ParseAssetsResult<'a>>>> {
|
||||
let r = match lang {
|
||||
ScriptLang::Python3 => windmill_parser_py::parse_assets(input, paths_storage),
|
||||
ScriptLang::DuckDb => windmill_parser_sql::parse_assets(input),
|
||||
ScriptLang::Deno | ScriptLang::Bun | ScriptLang::Nativets => {
|
||||
windmill_parser_ts::parse_assets(input, paths_storage)
|
||||
}
|
||||
_ => return Ok(None),
|
||||
};
|
||||
return r.map(Some);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user