-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41506fa
commit 8be3fac
Showing
6 changed files
with
193 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use serde::Deserialize; | ||
use wasm_bindgen::prelude::wasm_bindgen; | ||
use rattler_conda_types::ParseStrictness; | ||
|
||
#[wasm_bindgen(typescript_custom_section)] | ||
const PARSE_STRICTNESS_TS: &'static str = r#" | ||
/** | ||
* Defines how strict a parser should be when parsing an object from a string. | ||
* | ||
* @public | ||
*/ | ||
export type ParseStrictness = "strict" | "lenient"; | ||
"#; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
#[wasm_bindgen(js_name="ParseStrictness", typescript_type = "ParseStrictness")] | ||
pub type JsParseStrictness; | ||
} | ||
|
||
impl TryFrom<JsParseStrictness> for ParseStrictness { | ||
type Error = serde_wasm_bindgen::Error; | ||
|
||
fn try_from(value: JsParseStrictness) -> Result<Self, Self::Error> { | ||
#[derive(Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub enum EnumNames { | ||
Strict, | ||
Lenient, | ||
} | ||
|
||
match serde_wasm_bindgen::from_value(value.obj)? { | ||
EnumNames::Strict => Ok(ParseStrictness::Strict), | ||
EnumNames::Lenient => Ok(ParseStrictness::Lenient), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.