Skip to content

Commit

Permalink
qemu 3.1.0, rust 2018, docs.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx committed Dec 13, 2018
1 parent 130cdb3 commit 0bc5778
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 132 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ before_deploy:
- cd $TRAVIS_BUILD_DIR/parser
- cargo package
after_deploy:
- cd $TRAVIS_BUILD_DIR
- cargo pages-publish
- cd $TRAVIS_BUILD_DIR/spec
- cargo publish
- cd $TRAVIS_BUILD_DIR/parser
Expand Down
14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
[package]
name = "qapi"
version = "0.3.0"
version = "0.4.0" # keep in sync with html_root_url
authors = ["arcnmx"]
edition = "2018"

description = "QEMU QMP and Guest Agent API"
keywords = ["qemu", "qmp", "qga", "qapi"]

documentation = "http://arcnmx.github.io/qapi-rs/qapi"
documentation = "https://docs.rs/qapi"
repository = "https://github.com/arcnmx/qapi-rs"
readme = "README.md"
license = "MIT"

[package.metadata.docs.rs]
all-features = true

[badges]
travis-ci = { repository = "arcnmx/qapi-rs" }
maintenance = { status = "passively-maintained" }
Expand All @@ -20,9 +24,9 @@ serde = "^1.0.27"
serde_json = "^1.0.9"
qapi-spec = { version = "^0.2.0", path = "spec" }

log = { version = "^0.4.1", optional = true }
qapi-qga = { version = "^0.3.0", path = "qga", optional = true }
qapi-qmp = { version = "^0.3.0", path = "qmp", optional = true }
log = { version = "^0.4.6", optional = true }
qapi-qga = { version = "^0.4.0", path = "qga", optional = true }
qapi-qmp = { version = "^0.4.0", path = "qmp", optional = true }

[features]
qga = ["qapi-qga", "log"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ available](tokio/examples/).
[release-badge]: https://img.shields.io/crates/v/qapi.svg?style=flat-square
[cargo]: https://crates.io/crates/qapi
[docs-badge]: https://img.shields.io/badge/API-docs-blue.svg?style=flat-square
[docs]: http://arcnmx.github.io/qapi-rs/qapi/
[docs]: http://docs.rs/qapi/
[license-badge]: https://img.shields.io/badge/license-MIT-ff69b4.svg?style=flat-square
[license]: https://github.com/arcnmx/qapi-rs/blob/master/COPYING
7 changes: 4 additions & 3 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "qapi-codegen"
version = "0.2.1"
version = "0.3.0" # keep in sync with html_root_url
authors = ["arcnmx"]
edition = "2018"

description = "QEMU QAPI codegen helper"
keywords = ["qemu", "qmp", "qga", "qapi"]

documentation = "http://arcnmx.github.io/qapi-rs/qapi_codegen"
documentation = "https://docs.rs/qapi-codegen/"
repository = "https://github.com/arcnmx/qapi-rs"
readme = "../README.md"
license = "MIT"
Expand All @@ -16,4 +17,4 @@ travis-ci = { repository = "arcnmx/qapi-rs" }
maintenance = { status = "passively-maintained" }

[dependencies]
qapi-parser = { version = "^0.2.1", path = "../parser" }
qapi-parser = { version = "^0.3.0", path = "../parser" }
28 changes: 14 additions & 14 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate qapi_parser as parser;
#![doc(html_root_url = "http://docs.rs/qapi-codegen/0.3.0")]

use parser::{Parser, QemuFileRepo, QemuRepo, spec};
use parser::spec::Spec;
use qapi_parser::{Parser, QemuFileRepo, QemuRepo, spec};
use qapi_parser::spec::Spec;
use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::fs::File;
Expand Down Expand Up @@ -32,7 +32,7 @@ fn event_identifier(id: &str) -> String {
fn typename_s(ty: &str) -> String {
match ty {
"str" => "::std::string::String".into(),
"any" => "::qapi::Any".into(),
"any" => "::qapi_spec::Any".into(),
"null" => "()".into(),
"number" => "f64".into(),
"int8" => "i8".into(),
Expand Down Expand Up @@ -89,14 +89,14 @@ fn valuety(value: &spec::Value, pubvis: bool, super_name: &str) -> String {
let (attr, ty) = if base64 {
let ty = "Vec<u8>".into();
if value.optional {
(", with = \"qapi::base64_opt\"", ty)
(", with = \"::qapi_spec::base64_opt\"", ty)
} else {
(", with = \"qapi::base64\"", ty)
(", with = \"::qapi_spec::base64\"", ty)
}
} else if boxed {
("", format!("Box<{}>", ty))
} else if dict {
("", "::qapi::Dictionary".into())
("", "::qapi_spec::Dictionary".into())
} else if super_name == "guest-shutdown" && value.name == "mode" {
("", "GuestShutdownMode".into())
} else {
Expand Down Expand Up @@ -156,7 +156,7 @@ pub struct {}", type_identifier(&v.id))?;
match v.data {
spec::DataOrType::Data(ref data) => {
if v.id == "device_add" || v.id == "netdev_add" {
writeln!(self.out, "(pub ::qapi::Dictionary);")?;
writeln!(self.out, "(pub ::qapi_spec::Dictionary);")?;
} else {
writeln!(self.out, " {{")?;
for data in &data.fields {
Expand All @@ -173,14 +173,14 @@ pub struct {}", type_identifier(&v.id))?;
}

write!(self.out, "
impl ::qapi::Command for {} {{
impl ::qapi_spec::Command for {} {{
const NAME: &'static str = \"{}\";
type Ok = ", type_identifier(&v.id), v.id)?;
if let Some(ret) = v.returns {
writeln!(self.out, "{};", typename(&ret))
} else {
writeln!(self.out, "::qapi::Empty;")
writeln!(self.out, "::qapi_spec::Empty;")
}?;
writeln!(self.out, "}}")?;
},
Expand Down Expand Up @@ -229,7 +229,7 @@ pub struct {} {{
}
writeln!(self.out, "}}")?;
writeln!(self.out, "
impl ::qapi::Event for {} {{
impl ::qapi_spec::Event for {} {{
const NAME: &'static str = \"{}\";
}}", event_identifier(&v.id), v.id)?;
self.events.push(v);
Expand Down Expand Up @@ -258,7 +258,7 @@ pub enum {} {{
fn process_structs(&mut self) -> io::Result<()> {
for (id, discrim) in &self.struct_discriminators {
let ty = self.types.get_mut(id).ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, format!("could not find qapi type {}", id)))?;
let mut fields = replace(&mut ty.data.fields, Vec::new());
let fields = replace(&mut ty.data.fields, Vec::new());
ty.data.fields = fields.into_iter().filter(|base| &base.name != discrim).collect();
}

Expand Down Expand Up @@ -389,14 +389,14 @@ pub enum Event {{")?;
let id = event_identifier(&event.id);
writeln!(self.out, "\t#[serde(rename = \"{}\")] {} {{
{} data: {},
timestamp: ::qapi::Timestamp,
timestamp: ::qapi_spec::Timestamp,
}},", event.id, id, if event.data.is_empty() { "#[serde(default)] " } else { "" }, id)?;
}
writeln!(self.out, "}}")?;

writeln!(self.out, "
impl Event {{
pub fn timestamp(&self) -> ::qapi::Timestamp {{
pub fn timestamp(&self) -> ::qapi_spec::Timestamp {{
match *self {{")?;
for event in &self.events {
writeln!(self.out, "Event::{} {{ timestamp, .. }} => timestamp,", event_identifier(&event.id))?;
Expand Down
5 changes: 3 additions & 2 deletions parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "qapi-parser"
version = "0.2.1"
version = "0.3.0" # keep in sync with html_root_url
authors = ["arcnmx"]
edition = "2018"

description = "QEMU QAPI JSON specification parser"
keywords = ["qemu", "qmp", "qga", "qapi"]

documentation = "http://arcnmx.github.io/qapi-rs/qapi_parser"
documentation = "https://docs.rs/qapi-parser/"
repository = "https://github.com/arcnmx/qapi-rs"
readme = "../README.md"
license = "MIT"
Expand Down
8 changes: 3 additions & 5 deletions parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate serde;
#![doc(html_root_url = "http://docs.rs/qapi-parser/0.3.0")]

pub mod spec {
use std::collections::HashMap;
use std::fmt;
use serde::de::{Deserializer, Deserialize, Visitor, SeqAccess, Error};
use serde_derive::Deserialize;

#[derive(Debug, Clone, Deserialize)]
#[serde(untagged, rename_all = "lowercase")]
Expand Down Expand Up @@ -244,7 +242,7 @@ pub mod spec {
}
}

pub use spec::Spec;
pub use self::spec::Spec;

use std::path::{Path, PathBuf};
use std::ops::{Deref, DerefMut};
Expand Down
7 changes: 4 additions & 3 deletions qga/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "qapi-qga"
version = "0.3.0"
version = "0.4.0" # keep in sync with html_root_url
build = "build.rs"
authors = ["arcnmx"]
edition = "2018"

description = "QEMU Guest Agent protocol types"
keywords = ["qemu", "qga", "qapi"]

documentation = "http://arcnmx.github.io/qapi-rs/qapi_qga"
documentation = "https://docs.rs/qapi-qga/"
repository = "https://github.com/arcnmx/qapi-rs"
readme = "../README.md"
license = "MIT"
Expand All @@ -17,7 +18,7 @@ travis-ci = { repository = "arcnmx/qapi-rs" }
maintenance = { status = "passively-maintained" }

[build-dependencies]
qapi-codegen = { version = "^0.2.0", path = "../codegen" }
qapi-codegen = { version = "^0.3.0", path = "../codegen" }

[dependencies]
serde = "^1.0.78"
Expand Down
7 changes: 2 additions & 5 deletions qga/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#![allow(non_snake_case, non_camel_case_types)]

extern crate qapi_spec as qapi;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#![doc(html_root_url = "http://docs.rs/qapi-qga/0.4.0")]

include!(concat!(env!("OUT_DIR"), "/qga.rs"));

use std::{io, str, fmt, error};
use serde_derive::{Deserialize, Serialize};

#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
Expand Down
7 changes: 4 additions & 3 deletions qmp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "qapi-qmp"
version = "0.3.0"
version = "0.4.0" # keep in sync with html_root_url
build = "build.rs"
authors = ["arcnmx"]
edition = "2018"

description = "QEMU Machine Protocol types"
keywords = ["qemu", "qmp", "qapi"]

documentation = "http://arcnmx.github.io/qapi-rs/qapi_qmp"
documentation = "https://docs.rs/qapi-qmp/"
repository = "https://github.com/arcnmx/qapi-rs"
readme = "../README.md"
license = "MIT"
Expand All @@ -17,7 +18,7 @@ travis-ci = { repository = "arcnmx/qapi-rs" }
maintenance = { status = "passively-maintained" }

[build-dependencies]
qapi-codegen = { version = "^0.2.0", path = "../codegen" }
qapi-codegen = { version = "^0.3.0", path = "../codegen" }

[dependencies]
serde = "^1.0.78"
Expand Down
17 changes: 7 additions & 10 deletions qmp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#![allow(non_snake_case, non_camel_case_types)]

extern crate qapi_spec as qapi;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#![doc(html_root_url = "http://docs.rs/qapi-qmp/0.4.0")]

use std::string;
use serde_derive::{Deserialize, Serialize};

include!(concat!(env!("OUT_DIR"), "/qmp.rs"));

Expand All @@ -21,14 +18,14 @@ pub struct QapiCapabilities {
}

impl device_add {
pub fn new<P: IntoIterator<Item=(string::String, qapi::Any)>>(driver: string::String, id: Option<string::String>, bus: Option<string::String>, props: P) -> Self {
let mut dict = qapi::Dictionary::default();
dict.insert("driver".into(), qapi::Any::String(driver));
pub fn new<P: IntoIterator<Item=(string::String, qapi_spec::Any)>>(driver: string::String, id: Option<string::String>, bus: Option<string::String>, props: P) -> Self {
let mut dict = qapi_spec::Dictionary::default();
dict.insert("driver".into(), qapi_spec::Any::String(driver));
if let Some(id) = id {
dict.insert("id".into(), qapi::Any::String(id));
dict.insert("id".into(), qapi_spec::Any::String(id));
}
if let Some(bus) = bus {
dict.insert("bus".into(), qapi::Any::String(bus));
dict.insert("bus".into(), qapi_spec::Any::String(bus));
}
dict.extend(props);

Expand Down
5 changes: 3 additions & 2 deletions spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "qapi-spec"
version = "0.2.1"
version = "0.2.2"
authors = ["arcnmx"]
edition = "2018"

description = "QEMU QAPI common types"
keywords = ["qemu", "qmp", "qga", "qapi"]

documentation = "http://arcnmx.github.io/qapi-rs/qapi_spec"
documentation = "https://docs.rs/qapi-spec/"
repository = "https://github.com/arcnmx/qapi-rs"
readme = "../README.md"
license = "MIT"
Expand Down
Loading

0 comments on commit 0bc5778

Please sign in to comment.