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
Wolfgang Bumiller
818dc25478
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>
2019-08-08 11:14:47 +02:00
Wolfgang Bumiller
dfdf354b0d
macro: more quote -> quote_spanned changes
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 11:09:58 +02:00
Wolfgang Bumiller
af04fc5764
macro: remove unused add_verifiers
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-08 11:09:29 +02:00
Wolfgang Bumiller
ccce46eba4
formatting fixup
...
make fmt
(cargo fmt --all)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:14:23 +02:00
Wolfgang Bumiller
863a16a5bc
whitespace cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:13:37 +02:00
Wolfgang Bumiller
4c9a8b5c88
cleanup use statements
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:12:49 +02:00
Wolfgang Bumiller
f074a9e60b
cleanup Cargo.toml files
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:09:54 +02:00
Wolfgang Bumiller
1f11c4adf9
sys: rustfmt workaround
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 12:46:21 +02:00
Wolfgang Bumiller
63b17d4eb5
tools: Cargo.toml: cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 12:36:35 +02:00
Wolfgang Bumiller
97f41473db
rename tools::raw to tools::fd
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 12:36:24 +02:00
Dietmar Maurer
3497f97a7d
proxmox-tools/src/lib.rs: fix doc test
2019-08-05 10:12:08 +02:00
Wolfgang Bumiller
d78142302c
formatting fixup
...
add #[rustfmt::skip] to our macros...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 09:45:14 +02:00
Dietmar Maurer
d6d65be42e
add nodename helper (copied from proxmox-backup)
2019-08-03 17:00:02 +02:00
Dietmar Maurer
ce18d8c035
src/linux/procfs.rs: moved from proxmox-backup
2019-08-03 16:19:11 +02:00
Dietmar Maurer
51d891af5d
new helper create_dir_chown
...
moved from proxmox-backup.
2019-08-03 12:21:20 +02:00
Dietmar Maurer
9f63a6506e
src/fs.rs: new module for fs related helpers
2019-08-03 11:49:14 +02:00
Dietmar Maurer
909520d191
add src/linux/magic.rs - moved from proxmox-backup
2019-08-03 09:19:32 +02:00
Wolfgang Bumiller
e985dc8f84
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>
2019-08-01 14:40:13 +02:00
Wolfgang Bumiller
75e90ebb25
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>
2019-08-01 11:20:11 +02:00
Wolfgang Bumiller
ef13b38632
macro: improve error output
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-31 15:42:07 +02:00
Wolfgang Bumiller
3a36ff78df
macro: clear a warning
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-31 14:39:18 +02:00
Wolfgang Bumiller
14acfcd5cd
macro: recurse into struct field verifiers
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-31 14:35:00 +02:00
Wolfgang Bumiller
3c31381fb2
macro: support 'pattern' verifier in structs
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-31 14:32:35 +02:00
Wolfgang Bumiller
26e4b205ac
tools: add remaining common regexps
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-31 11:45:45 +02:00