Skip to content

Commit eb0cdc1

Browse files
committed
[model-gateway] wasm: some minor improvements (sgl-project#12471)
Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
1 parent ad46d76 commit eb0cdc1

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

sgl-router/src/wasm/module_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl WasmModuleManager {
8585
Ok(hasher.finalize().into())
8686
}
8787

88-
fn validate_module_descriptor(&self, descriptor: WasmModuleDescriptor) -> Result<()> {
88+
fn validate_module_descriptor(&self, descriptor: &WasmModuleDescriptor) -> Result<()> {
8989
if descriptor.name.is_empty() {
9090
return Err(WasmModuleError::InvalidDescriptor(
9191
"Module name cannot be empty".to_string(),
@@ -109,7 +109,7 @@ impl WasmModuleManager {
109109

110110
pub fn add_module(&self, descriptor: WasmModuleDescriptor) -> Result<Uuid> {
111111
// validate the module descriptor
112-
self.validate_module_descriptor(descriptor.clone())?;
112+
self.validate_module_descriptor(&descriptor)?;
113113

114114
// calculate the sha256 hash of the module file
115115
let sha256_hash = self.calculate_sha256_hash(&descriptor.file_path)?;

sgl-router/src/wasm/types.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -86,36 +86,6 @@ impl WasmComponentOutput {
8686
}
8787
}
8888

89-
/// Helper trait for converting from WIT types to component input
90-
pub trait ToComponentInput {
91-
fn to_component_input(self) -> WasmComponentInput;
92-
}
93-
94-
/// Helper trait for converting from component output to WIT types
95-
pub trait FromComponentOutput {
96-
fn from_component_output(output: &WasmComponentOutput) -> Option<&Self>;
97-
}
98-
99-
impl ToComponentInput for middleware_types::Request {
100-
fn to_component_input(self) -> WasmComponentInput {
101-
WasmComponentInput::MiddlewareRequest(self)
102-
}
103-
}
104-
105-
impl ToComponentInput for middleware_types::Response {
106-
fn to_component_input(self) -> WasmComponentInput {
107-
WasmComponentInput::MiddlewareResponse(self)
108-
}
109-
}
110-
111-
impl FromComponentOutput for middleware_types::Action {
112-
fn from_component_output(output: &WasmComponentOutput) -> Option<&Self> {
113-
match output {
114-
WasmComponentOutput::MiddlewareAction(action) => Some(action),
115-
}
116-
}
117-
}
118-
11989
pub struct WasiState {
12090
pub ctx: WasiCtx,
12191
pub table: ResourceTable,

0 commit comments

Comments
 (0)