Commit Graph

886 Commits

Author SHA1 Message Date
Wolfgang Bumiller
09d84f6634 [clippy] tools: lifetimes and constants
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:42:05 +02:00
Wolfgang Bumiller
a11f6e88f8 [clippy] sys: simplifications and optimizations
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:28:44 +02:00
Wolfgang Bumiller
05b432c422 [clippy] macro: remaining clippy lints
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:24:37 +02:00
Wolfgang Bumiller
c241be9e6a [clippy] macro: ident implements comparsion with strings
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:20:49 +02:00
Wolfgang Bumiller
7f2ae4f272 [clippy] api-test: remove unnecessary lifetimes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:15:03 +02:00
Wolfgang Bumiller
d06b2b277c [clippy] api-test: remaining changes to memory.rs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:09:41 +02:00
Wolfgang Bumiller
c6e022523b [clippy] api-test: more int by value passing
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:07:07 +02:00
Wolfgang Bumiller
dffed98348 [clippy] api-test: simplify some loops
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:04:57 +02:00
Wolfgang Bumiller
adf6727072 [clippy] api-test: generalize HashSet impls and closure cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:04:55 +02:00
Wolfgang Bumiller
4a33af4387 [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>
2019-08-21 16:59:19 +02:00
Wolfgang Bumiller
27f954f632 [clippy] api-test: use trailing zeros, pattern efficiency
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 16:56:22 +02:00
Wolfgang Bumiller
2551fe4a74 [clippy] api-test: pass Copy integer by value
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 16:53:19 +02:00
Wolfgang Bumiller
45b5839e7e replace std::mem::uninitialized
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 16:49:12 +02:00
Wolfgang Bumiller
e59456e0b7 tools: fs: rename CreateOptions::empty to new
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 12:01:43 +02:00
Wolfgang Bumiller
47fdbc6a32 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>
2019-08-21 11:51:45 +02:00
Wolfgang Bumiller
aadb47a292 update nix to 0.15 for mkdirat
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 11:51:45 +02:00
Wolfgang Bumiller
4a1c914827 tools: fd: improve drop handler and add some helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 11:51:45 +02:00
Wolfgang Bumiller
68f4a68bc1 formatting cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 10:15:42 +02:00
Wolfgang Bumiller
acbf549bf0 tools: fs: import unistd::{Uid,Gid} fully
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 10:15:21 +02:00
Wolfgang Bumiller
0eadf624e0 upgrade to tokio-0.2.0-alpha.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-20 12:22:13 +02:00
Wolfgang Bumiller
b7ff60bdd3 use tokio's current alpha.1 release
one less git dependency to track for now

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-19 12:21:05 +02:00
Wolfgang Bumiller
abc32ba70f cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 13:15:39 +02:00
Wolfgang Bumiller
2ecd147036 tools: add borrow::Tied with example docs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 12:36:27 +02:00
Wolfgang Bumiller
025eaf5519 api-macro: fix non-async test case after adding verifiers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 12:21:32 +02:00
Wolfgang Bumiller
9fd9bd53fd api-test: update curl examples
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 10:20:26 +02:00
Wolfgang Bumiller
bb937395f7 macro: functions: call verify() on all parameters
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 10:18:33 +02:00
Wolfgang Bumiller
3d15cca7d6 api-test: add a short example shell script for now
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 09:49:22 +02:00
Wolfgang Bumiller
021a381f18 api-test: add example with a more complex struct
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 09:44:40 +02:00
Wolfgang Bumiller
5be4143d92 api: allow () type, but panic when used as CLI input
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-16 09:44:25 +02:00
Wolfgang Bumiller
a7b9c8d89e fixup tests for router change
Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
2019-08-15 20:26:18 +02:00
Wolfgang Bumiller
8b77b3d08c api-test: add a json-body multi-parameter test method
Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
2019-08-15 11:03:10 +02:00
Wolfgang Bumiller
82f8df963e 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>
2019-08-15 11:02:09 +02:00
Wolfgang Bumiller
6705d13424 api-test: comments/cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
2019-08-15 10:28:14 +02:00
Wolfgang Bumiller
bb2639bf40 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-12 14:34:23 +02:00
Wolfgang Bumiller
8e24ada75a macro: support deriving Display for newtypes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-12 14:01:21 +02:00
Wolfgang Bumiller
50f5115718 macro: fix enum verify method
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-12 14:00:59 +02:00
Wolfgang Bumiller
37cf2e6208 macro: fixup previous commit: remove hardcoded error
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-12 13:30:35 +02:00
Wolfgang Bumiller
0046e5e33a 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>
2019-08-12 12:00:12 +02:00
Wolfgang Bumiller
fb5670c5b5 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>
2019-08-12 10:42:19 +02:00
Wolfgang Bumiller
169bf79c72 formatting cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-09 12:42:06 +02:00
Wolfgang Bumiller
ed503f689d macro: split enum handler into separate module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-09 12:42:06 +02:00
Wolfgang Bumiller
59d0c72642 macro: split struct handlers into separate submodules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-09 12:42:06 +02:00
Wolfgang Bumiller
841c2a218d macro: split function handler into separate file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-09 12:42:06 +02:00
Wolfgang Bumiller
62b5798314 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>
2019-08-09 08:44:48 +02:00
Wolfgang Bumiller
080f62916e 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>
2019-08-08 14:04:28 +02:00
Wolfgang Bumiller
cad8f2f1c3 macro: implement #[derive(FromStr)] for newtypes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 13:54:17 +02:00
Wolfgang Bumiller
e3273d6172 formatting cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 13:13:35 +02:00
Wolfgang Bumiller
cfa6f0f67f cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 13:13:19 +02:00
Wolfgang Bumiller
bb3e2859e4 macro: derive ser/de for newtypes just like structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 11:29:12 +02:00
Wolfgang Bumiller
a53e8c5e82 macro: make sure errors are separated
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 11:17:37 +02:00