]> git.proxmox.com Git - proxmox.git/log
proxmox.git
5 years ago[clippy] macro: ident implements comparsion with strings
Wolfgang Bumiller [Thu, 22 Aug 2019 07:20:28 +0000 (09:20 +0200)]
[clippy] macro: ident implements comparsion with strings

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: remove unnecessary lifetimes
Wolfgang Bumiller [Thu, 22 Aug 2019 07:15:03 +0000 (09:15 +0200)]
[clippy] api-test: remove unnecessary lifetimes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: remaining changes to memory.rs
Wolfgang Bumiller [Thu, 22 Aug 2019 07:09:41 +0000 (09:09 +0200)]
[clippy] api-test: remaining changes to memory.rs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: more int by value passing
Wolfgang Bumiller [Thu, 22 Aug 2019 07:07:07 +0000 (09:07 +0200)]
[clippy] api-test: more int by value passing

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: simplify some loops
Wolfgang Bumiller [Thu, 22 Aug 2019 07:04:38 +0000 (09:04 +0200)]
[clippy] api-test: simplify some loops

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: generalize HashSet impls and closure cleanups
Wolfgang Bumiller [Thu, 22 Aug 2019 07:02:36 +0000 (09:02 +0200)]
[clippy] api-test: generalize HashSet impls and closure cleanups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy]: api-test: fix unsuffixed memory values
Wolfgang Bumiller [Wed, 21 Aug 2019 14:59:15 +0000 (16:59 +0200)]
[clippy]: api-test: fix unsuffixed memory values

Clippy actually noticed that the else branch was the same as
the one for the 'b' suffix...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: use trailing zeros, pattern efficiency
Wolfgang Bumiller [Wed, 21 Aug 2019 14:56:22 +0000 (16:56 +0200)]
[clippy] api-test: use trailing zeros, pattern efficiency

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years ago[clippy] api-test: pass Copy integer by value
Wolfgang Bumiller [Wed, 21 Aug 2019 14:53:19 +0000 (16:53 +0200)]
[clippy] api-test: pass Copy integer by value

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoreplace std::mem::uninitialized
Wolfgang Bumiller [Wed, 21 Aug 2019 14:49:12 +0000 (16:49 +0200)]
replace std::mem::uninitialized

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: fs: rename CreateOptions::empty to new
Wolfgang Bumiller [Wed, 21 Aug 2019 10:01:43 +0000 (12:01 +0200)]
tools: fs: rename CreateOptions::empty to new

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: fs: add create_path and CreateOptions
Wolfgang Bumiller [Wed, 21 Aug 2019 09:50:32 +0000 (11:50 +0200)]
tools: fs: add create_path and CreateOptions

To allow creating paths recursively with options. (Basically
extends `std::fs::create_dir_all`.)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoupdate nix to 0.15 for mkdirat
Wolfgang Bumiller [Wed, 21 Aug 2019 09:17:11 +0000 (11:17 +0200)]
update nix to 0.15 for mkdirat

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: fd: improve drop handler and add some helpers
Wolfgang Bumiller [Wed, 21 Aug 2019 08:52:37 +0000 (10:52 +0200)]
tools: fd: improve drop handler and add some helpers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting cleanup
Wolfgang Bumiller [Wed, 21 Aug 2019 08:15:42 +0000 (10:15 +0200)]
formatting cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: fs: import unistd::{Uid,Gid} fully
Wolfgang Bumiller [Wed, 21 Aug 2019 08:15:21 +0000 (10:15 +0200)]
tools: fs: import unistd::{Uid,Gid} fully

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoupgrade to tokio-0.2.0-alpha.2
Wolfgang Bumiller [Tue, 20 Aug 2019 10:22:13 +0000 (12:22 +0200)]
upgrade to tokio-0.2.0-alpha.2

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agouse tokio's current alpha.1 release
Wolfgang Bumiller [Mon, 19 Aug 2019 10:21:04 +0000 (12:21 +0200)]
use tokio's current alpha.1 release

one less git dependency to track for now

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup
Wolfgang Bumiller [Fri, 16 Aug 2019 11:15:39 +0000 (13:15 +0200)]
cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: add borrow::Tied with example docs
Wolfgang Bumiller [Fri, 16 Aug 2019 10:36:27 +0000 (12:36 +0200)]
tools: add borrow::Tied with example docs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi-macro: fix non-async test case after adding verifiers
Wolfgang Bumiller [Fri, 16 Aug 2019 10:21:31 +0000 (12:21 +0200)]
api-macro: fix non-async test case after adding verifiers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi-test: update curl examples
Wolfgang Bumiller [Fri, 16 Aug 2019 08:20:26 +0000 (10:20 +0200)]
api-test: update curl examples

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: functions: call verify() on all parameters
Wolfgang Bumiller [Fri, 16 Aug 2019 08:18:33 +0000 (10:18 +0200)]
macro: functions: call verify() on all parameters

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi-test: add a short example shell script for now
Wolfgang Bumiller [Fri, 16 Aug 2019 07:49:22 +0000 (09:49 +0200)]
api-test: add a short example shell script for now

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi-test: add example with a more complex struct
Wolfgang Bumiller [Fri, 16 Aug 2019 07:44:40 +0000 (09:44 +0200)]
api-test: add example with a more complex struct

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi: allow () type, but panic when used as CLI input
Wolfgang Bumiller [Fri, 16 Aug 2019 07:44:25 +0000 (09:44 +0200)]
api: allow () type, but panic when used as CLI input

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agofixup tests for router change
Wolfgang Bumiller [Thu, 15 Aug 2019 18:26:18 +0000 (20:26 +0200)]
fixup tests for router change

Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
5 years agoapi-test: add a json-body multi-parameter test method
Wolfgang Bumiller [Thu, 15 Aug 2019 09:03:10 +0000 (11:03 +0200)]
api-test: add a json-body multi-parameter test method

Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
5 years agoapi: router: return Map on lookup
Wolfgang Bumiller [Thu, 15 Aug 2019 09:02:08 +0000 (11:02 +0200)]
api: router: return Map on lookup

Instead of a Value, makes it easier to use the parameters
later on.

Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
5 years agoapi-test: comments/cleanup
Wolfgang Bumiller [Thu, 15 Aug 2019 08:27:25 +0000 (10:27 +0200)]
api-test: comments/cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
5 years agoformatting fixup
Wolfgang Bumiller [Mon, 12 Aug 2019 12:34:23 +0000 (14:34 +0200)]
formatting fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: support deriving Display for newtypes
Wolfgang Bumiller [Mon, 12 Aug 2019 12:01:21 +0000 (14:01 +0200)]
macro: support deriving Display for newtypes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: fix enum verify method
Wolfgang Bumiller [Mon, 12 Aug 2019 12:00:59 +0000 (14:00 +0200)]
macro: fix enum verify method

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: fixup previous commit: remove hardcoded error
Wolfgang Bumiller [Mon, 12 Aug 2019 11:30:34 +0000 (13:30 +0200)]
macro: fixup previous commit: remove hardcoded error

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: experimental support for enums with values
Wolfgang Bumiller [Mon, 12 Aug 2019 10:00:11 +0000 (12:00 +0200)]
macro: experimental support for enums with values

enum Foo {
    Variant1(Type),          // allowed
    Variant2(Type, Type),    // not allowed
    Variant3 { name: Type }, // not allowed
}

In the simple case of a single type we simply drop the
automatically derived `FromStr`/`Display` impls and expect
the user to implement them manually, while in the `verify()`
method we simply match on self and forward to the inner
verifier.

So to get "tagged unions" in the API, implement a proper
API type for each variant, then add an enum with 1-tuple
variants.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: remove exact futures-preview version
Wolfgang Bumiller [Mon, 12 Aug 2019 08:42:18 +0000 (10:42 +0200)]
macro: remove exact futures-preview version

Otherwise we have .16 and .17 in the same project. And we
can't go to .18 currently until hyper/tokio git-master are
in sync again.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting cleanup
Wolfgang Bumiller [Fri, 9 Aug 2019 10:41:53 +0000 (12:41 +0200)]
formatting cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: split enum handler into separate module
Wolfgang Bumiller [Fri, 9 Aug 2019 10:40:43 +0000 (12:40 +0200)]
macro: split enum handler into separate module

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: split struct handlers into separate submodules
Wolfgang Bumiller [Fri, 9 Aug 2019 10:36:12 +0000 (12:36 +0200)]
macro: split struct handlers into separate submodules

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: split function handler into separate file
Wolfgang Bumiller [Fri, 9 Aug 2019 07:18:02 +0000 (09:18 +0200)]
macro: split function handler into separate file

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoimport Cargo.lock
Wolfgang Bumiller [Fri, 9 Aug 2019 06:44:48 +0000 (08:44 +0200)]
import Cargo.lock

We use some crates from their git-master branch and they can
sometimes conflict, so this should pin working revisions of
all crates.

Furthermore, when we start packaging things we'll need to
keep the lock file around as a reference to know the exact
sources we built packages from.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: errors shouldn't discard the code
Wolfgang Bumiller [Thu, 8 Aug 2019 12:04:27 +0000 (14:04 +0200)]
macro: errors shouldn't discard the code

Otherwise we'll get even more errors.
Consider this example:

    #[api(...)]
    struct Foo { ... }
    impl MyTrait for Foo { ... }

If the #[api] macro fails and does not at least produce the
`struct Foo{}` along with its `compile_error!()` output,
then in addition to our macro errors, we'll see errors about
trying to implement `MyTrait` for an unknown thing called
`Foo`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: implement #[derive(FromStr)] for newtypes
Wolfgang Bumiller [Thu, 8 Aug 2019 11:53:24 +0000 (13:53 +0200)]
macro: implement #[derive(FromStr)] for newtypes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting cleanup
Wolfgang Bumiller [Thu, 8 Aug 2019 11:13:35 +0000 (13:13 +0200)]
formatting cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup
Wolfgang Bumiller [Thu, 8 Aug 2019 11:13:19 +0000 (13:13 +0200)]
cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: derive ser/de for newtypes just like structs
Wolfgang Bumiller [Thu, 8 Aug 2019 09:29:12 +0000 (11:29 +0200)]
macro: derive ser/de for newtypes just like structs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: make sure errors are separated
Wolfgang Bumiller [Thu, 8 Aug 2019 09:17:37 +0000 (11:17 +0200)]
macro: make sure errors are separated

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: factor out newtype handler
Wolfgang Bumiller [Thu, 8 Aug 2019 09:12:07 +0000 (11:12 +0200)]
macro: factor out newtype handler

Reuse verifier code of structs fields. Add handling of
'validate' methods for fields.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: more quote -> quote_spanned changes
Wolfgang Bumiller [Thu, 8 Aug 2019 09:09:58 +0000 (11:09 +0200)]
macro: more quote -> quote_spanned changes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: remove unused add_verifiers
Wolfgang Bumiller [Thu, 8 Aug 2019 09:09:29 +0000 (11:09 +0200)]
macro: remove unused add_verifiers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting fixup
Wolfgang Bumiller [Mon, 5 Aug 2019 12:14:09 +0000 (14:14 +0200)]
formatting fixup

make fmt
(cargo fmt --all)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agowhitespace cleanup
Wolfgang Bumiller [Mon, 5 Aug 2019 12:13:37 +0000 (14:13 +0200)]
whitespace cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup use statements
Wolfgang Bumiller [Mon, 5 Aug 2019 12:12:49 +0000 (14:12 +0200)]
cleanup use statements

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup Cargo.toml files
Wolfgang Bumiller [Mon, 5 Aug 2019 12:09:54 +0000 (14:09 +0200)]
cleanup Cargo.toml files

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agosys: rustfmt workaround
Wolfgang Bumiller [Mon, 5 Aug 2019 10:46:21 +0000 (12:46 +0200)]
sys: rustfmt workaround

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: Cargo.toml: cleanup
Wolfgang Bumiller [Mon, 5 Aug 2019 10:36:35 +0000 (12:36 +0200)]
tools: Cargo.toml: cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agorename tools::raw to tools::fd
Wolfgang Bumiller [Mon, 5 Aug 2019 10:36:24 +0000 (12:36 +0200)]
rename tools::raw to tools::fd

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoproxmox-tools/src/lib.rs: fix doc test
Dietmar Maurer [Mon, 5 Aug 2019 08:11:45 +0000 (10:11 +0200)]
proxmox-tools/src/lib.rs: fix doc test

5 years agoformatting fixup
Wolfgang Bumiller [Fri, 2 Aug 2019 09:26:40 +0000 (11:26 +0200)]
formatting fixup

add #[rustfmt::skip] to our macros...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoadd nodename helper (copied from proxmox-backup)
Dietmar Maurer [Sat, 3 Aug 2019 15:00:02 +0000 (17:00 +0200)]
add nodename helper (copied from proxmox-backup)

5 years agosrc/linux/procfs.rs: moved from proxmox-backup
Dietmar Maurer [Sat, 3 Aug 2019 14:19:11 +0000 (16:19 +0200)]
src/linux/procfs.rs: moved from proxmox-backup

5 years agonew helper create_dir_chown
Dietmar Maurer [Sat, 3 Aug 2019 10:21:20 +0000 (12:21 +0200)]
new helper create_dir_chown

moved from proxmox-backup.

5 years agosrc/fs.rs: new module for fs related helpers
Dietmar Maurer [Sat, 3 Aug 2019 09:49:14 +0000 (11:49 +0200)]
src/fs.rs: new module for fs related helpers

5 years agoadd src/linux/magic.rs - moved from proxmox-backup
Dietmar Maurer [Sat, 3 Aug 2019 07:19:32 +0000 (09:19 +0200)]
add src/linux/magic.rs - moved from proxmox-backup

5 years agoapi-test: import struct tests
Wolfgang Bumiller [Thu, 1 Aug 2019 12:40:12 +0000 (14:40 +0200)]
api-test: import struct tests

This is a bigger set of tests for the type-side (mostly for
`struct`s) of the #[api] macro, tasting serialization and
verifiers in various forms.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi: support HashSet<String> as api type
Wolfgang Bumiller [Thu, 1 Aug 2019 09:20:10 +0000 (11:20 +0200)]
api: support HashSet<String> as api type

This is just an array of strings in json, or a
semicolon-separated string on the command line.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: improve error output
Wolfgang Bumiller [Wed, 31 Jul 2019 13:42:05 +0000 (15:42 +0200)]
macro: improve error output

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: clear a warning
Wolfgang Bumiller [Wed, 31 Jul 2019 12:39:18 +0000 (14:39 +0200)]
macro: clear a warning

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: recurse into struct field verifiers
Wolfgang Bumiller [Wed, 31 Jul 2019 12:35:00 +0000 (14:35 +0200)]
macro: recurse into struct field verifiers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: support 'pattern' verifier in structs
Wolfgang Bumiller [Wed, 31 Jul 2019 12:32:35 +0000 (14:32 +0200)]
macro: support 'pattern' verifier in structs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: add remaining common regexps
Wolfgang Bumiller [Wed, 31 Jul 2019 09:45:45 +0000 (11:45 +0200)]
tools: add remaining common regexps

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotools: add common_regex with IP_REGEX for now
Wolfgang Bumiller [Wed, 31 Jul 2019 09:45:21 +0000 (11:45 +0200)]
tools: add common_regex with IP_REGEX for now

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting fixup
Wolfgang Bumiller [Tue, 30 Jul 2019 13:20:55 +0000 (15:20 +0200)]
formatting fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: support serialize_with and deserialize_with
Wolfgang Bumiller [Tue, 30 Jul 2019 13:19:51 +0000 (15:19 +0200)]
macro: support serialize_with and deserialize_with

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: don't enforce the AsOptionStr type on formats
Wolfgang Bumiller [Tue, 30 Jul 2019 08:33:07 +0000 (10:33 +0200)]
macro: don't enforce the AsOptionStr type on formats

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi, macro: implement 'format' verifier for structs
Wolfgang Bumiller [Tue, 30 Jul 2019 08:06:32 +0000 (10:06 +0200)]
api, macro: implement 'format' verifier for structs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi: macro: implement minimum/maximum_length checks
Wolfgang Bumiller [Mon, 29 Jul 2019 12:40:04 +0000 (14:40 +0200)]
api: macro: implement minimum/maximum_length checks

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi: verify: rename Verify to TestMinMax
Wolfgang Bumiller [Mon, 29 Jul 2019 12:30:32 +0000 (14:30 +0200)]
api: verify: rename Verify to TestMinMax

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi: add helper module for verifiers
Wolfgang Bumiller [Mon, 29 Jul 2019 12:16:04 +0000 (14:16 +0200)]
api: add helper module for verifiers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agorefactor struct handling
Wolfgang Bumiller [Mon, 29 Jul 2019 10:00:51 +0000 (12:00 +0200)]
refactor struct handling

less spaghetti code accumulation, more purpose oriented
functions

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: disable derive_default for now
Wolfgang Bumiller [Fri, 19 Jul 2019 13:24:39 +0000 (15:24 +0200)]
macro: disable derive_default for now

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: fixup: don't create unwanted default impl snippets
Wolfgang Bumiller [Fri, 19 Jul 2019 13:20:45 +0000 (15:20 +0200)]
macro: fixup: don't create unwanted default impl snippets

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: partial support for automatic Default derivation
Wolfgang Bumiller [Fri, 19 Jul 2019 13:17:25 +0000 (15:17 +0200)]
macro: partial support for automatic Default derivation

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: support Option in deserialization
Wolfgang Bumiller [Fri, 19 Jul 2019 12:50:23 +0000 (14:50 +0200)]
macro: support Option in deserialization

When deserializing we currently expect all fields to be
available, but we actually want Option types to be truly
optional...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting cleanup
Wolfgang Bumiller [Fri, 19 Jul 2019 12:30:48 +0000 (14:30 +0200)]
formatting cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoimplement accessors for types with defaults
Wolfgang Bumiller [Fri, 19 Jul 2019 12:09:15 +0000 (14:09 +0200)]
implement accessors for types with defaults

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoapi: add a meta module to help with macro impls
Wolfgang Bumiller [Fri, 19 Jul 2019 12:08:55 +0000 (14:08 +0200)]
api: add a meta module to help with macro impls

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agodefault to not serializing None options
Wolfgang Bumiller [Fri, 19 Jul 2019 11:22:18 +0000 (13:22 +0200)]
default to not serializing None options

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup
Wolfgang Bumiller [Fri, 19 Jul 2019 09:07:10 +0000 (11:07 +0200)]
cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: replace named struct handler
Wolfgang Bumiller [Fri, 19 Jul 2019 09:03:37 +0000 (11:03 +0200)]
macro: replace named struct handler

We now derive Serialize and Deserialize automatically.
This way we'll be able to add verifiers right into the
structs, support our 'rename' functionality, and our
'default' handling etc. which needs to be compatible with
what we have in perl.
Ideally this will also give us the option to mark structs as
being perl-compatible "property strings"
(PVE::JSONSchema::parse_property_string()) and automatically
derive FromStr for structs on demand.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: error handling
Wolfgang Bumiller [Fri, 19 Jul 2019 08:04:38 +0000 (10:04 +0200)]
macro: error handling

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: common defs: add default, and sort
Wolfgang Bumiller [Fri, 19 Jul 2019 08:01:59 +0000 (10:01 +0200)]
macro: common defs: add default, and sort

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: improved error output
Wolfgang Bumiller [Fri, 19 Jul 2019 07:58:07 +0000 (09:58 +0200)]
macro: improved error output

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: named struct: allow short form for fields
Wolfgang Bumiller [Thu, 18 Jul 2019 13:05:26 +0000 (15:05 +0200)]
macro: named struct: allow short form for fields

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: add spans to more errors
Wolfgang Bumiller [Thu, 18 Jul 2019 12:59:09 +0000 (14:59 +0200)]
macro: add spans to more errors

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: ability to rename enum variants via an attribute
Wolfgang Bumiller [Thu, 18 Jul 2019 12:52:25 +0000 (14:52 +0200)]
macro: ability to rename enum variants via an attribute

In PVE we have multiple different enum types: hyphenated,
all-caps, underscores.

By default our api-macro enums will convert CamelCase to
underscores, so we need a way to represent the rest:

enum AnEnum {
CaseOne, // becomes "case_one",
#[api(rename = "case-two")]
CaseTwo, // "case-two",
#[api(rename = "CASE_THREE")]
CaseThree,
}

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: cleanup error handling, remove error module
Wolfgang Bumiller [Thu, 18 Jul 2019 12:41:26 +0000 (14:41 +0200)]
macro: cleanup error handling, remove error module

syn::Error already covers this

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoformatting cleanup
Wolfgang Bumiller [Thu, 18 Jul 2019 11:58:26 +0000 (13:58 +0200)]
formatting cleanup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: more error handling improvements
Wolfgang Bumiller [Thu, 18 Jul 2019 11:57:51 +0000 (13:57 +0200)]
macro: more error handling improvements

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agomacro: add types.rs, preserve Span for Expressions
Wolfgang Bumiller [Thu, 18 Jul 2019 11:54:51 +0000 (13:54 +0200)]
macro: add types.rs, preserve Span for Expressions

Move the Name type into types.rs and make it hashable.
Expression::Object not contains an Object where the
hashmap's key is a Name and therefore preserves the Span of
all the keys for better error messages.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>