mirror of
https://github.com/fluencelabs/interface-types
synced 2024-12-04 15:20:20 +00:00
improve version parsing
This commit is contained in:
parent
ab76621355
commit
00582bd7c3
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -210,7 +210,7 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-interface-types-fl"
|
||||
version = "0.18.0"
|
||||
version = "0.18.1"
|
||||
dependencies = [
|
||||
"fluence-it-types",
|
||||
"it-to-bytes",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-interface-types-fl"
|
||||
version = "0.18.0"
|
||||
version = "0.18.1"
|
||||
description = "WebAssembly Interface Types library for Wasmer"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
|
@ -379,9 +379,22 @@ impl Parse<'_> for FunctionType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
struct Version(pub String);
|
||||
|
||||
impl Parse<'_> for Version {
|
||||
fn parse(parser: Parser<'_>) -> Result<Self> {
|
||||
parser.parse::<keyword::version>()?;
|
||||
let version = parser.parse()?;
|
||||
|
||||
Ok(Version(version))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
enum Interface<'a> {
|
||||
Version(String),
|
||||
Version(Version),
|
||||
Type(Type),
|
||||
Import(Import<'a>),
|
||||
Adapter(Adapter),
|
||||
@ -592,7 +605,7 @@ impl<'a> Parse<'a> for Interfaces<'a> {
|
||||
}
|
||||
|
||||
fn try_handle_version(
|
||||
version_str: &str,
|
||||
sdk_version: &Version,
|
||||
version: &mut Option<semver::Version>,
|
||||
parser: &Parser<'_>,
|
||||
) -> Result<()> {
|
||||
@ -605,7 +618,7 @@ fn try_handle_version(
|
||||
));
|
||||
}
|
||||
|
||||
let parsed_version = semver::Version::from_str(version_str)
|
||||
let parsed_version = semver::Version::from_str(&sdk_version.0)
|
||||
.map_err(|e| wast::Error::new(parser.cur_span(), format!("version is corrupted: {}", e)))?;
|
||||
*version = Some(parsed_version);
|
||||
|
||||
|
@ -296,7 +296,7 @@ impl<'input> ToString for &Interfaces<'input> {
|
||||
}
|
||||
};
|
||||
|
||||
output.push_str("Version: ");
|
||||
output.push_str("(@interface version ");
|
||||
output.push_str(&self.version.to_string());
|
||||
separator(&mut output);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user