1#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq, Eq, Hash)]
2pub struct UtUpload {
3 pub url: String,
4 #[serde(rename = "appUrl")]
5 pub app_url: String,
6 #[serde(rename = "fileHash")]
7 pub file_hash: String,
8}
9impl TryFrom<&web_sys::wasm_bindgen::JsValue> for UtUpload {
10 type Error = web_sys::wasm_bindgen::JsValue;
11 fn try_from(value: &web_sys::wasm_bindgen::JsValue) -> Result<Self, Self::Error> {
12 let js_str = web_sys::js_sys::JSON::stringify(value)?;
13 let str = js_str
14 .as_string()
15 .ok_or_else(|| web_sys::wasm_bindgen::JsValue::from_str("Failed to stringify JSON"))?;
16 let presigned_url: Self = serde_json::from_str(&str).map_err(|e| {
17 web_sys::wasm_bindgen::JsValue::from_str(&format!("Failed to parse JSON: {}", e))
18 })?;
19 Ok(presigned_url)
20 }
21}
22impl TryFrom<web_sys::wasm_bindgen::JsValue> for UtUpload {
23 type Error = web_sys::wasm_bindgen::JsValue;
24 fn try_from(value: web_sys::wasm_bindgen::JsValue) -> Result<Self, Self::Error> {
25 Self::try_from(&value)
26 }
27}