parse_assets match case in rust

This commit is contained in:
Diego Imbert
2025-07-04 00:40:17 +02:00
parent 7c48fe8f94
commit aa5575da79
3 changed files with 21 additions and 0 deletions
+1
View File
@@ -14913,6 +14913,7 @@ dependencies = [
"url",
"uuid",
"windmill-macros",
"windmill-parser",
"windmill-parser-py",
"windmill-parser-sql",
"windmill-parser-ts",
+1
View File
@@ -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 }
+19
View File
@@ -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);
}