fix(interface): harden generated public API
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
use wip_interface::interface;
|
||||
|
||||
#[interface]
|
||||
pub trait AsyncOperation {
|
||||
async fn status(&self) -> wip_interface::OperationResult<String>;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: async operations are not supported
|
||||
--> tests/ui/async_operation.rs:5:5
|
||||
|
|
||||
5 | async fn status(&self) -> wip_interface::OperationResult<String>;
|
||||
| ^^^^^
|
||||
@@ -0,0 +1,10 @@
|
||||
use wip_interface::interface;
|
||||
|
||||
#[interface]
|
||||
pub trait DefaultMethod {
|
||||
fn status(&self) -> wip_interface::OperationResult<String> {
|
||||
Ok(String::new())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
error: WIP operation methods must not have a body
|
||||
--> tests/ui/default_method.rs:5:64
|
||||
|
|
||||
5 | fn status(&self) -> wip_interface::OperationResult<String> {
|
||||
| ________________________________________________________________^
|
||||
6 | | Ok(String::new())
|
||||
7 | | }
|
||||
| |_____^
|
||||
@@ -0,0 +1,8 @@
|
||||
use wip_interface::WipType;
|
||||
|
||||
#[derive(WipType)]
|
||||
struct GenericDto<T> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: generic DTOs are not supported by `WipType`
|
||||
--> tests/ui/generic_dto.rs:4:18
|
||||
|
|
||||
4 | struct GenericDto<T> {
|
||||
| ^^^
|
||||
@@ -0,0 +1,8 @@
|
||||
use wip_interface::WipType;
|
||||
|
||||
#[derive(WipType)]
|
||||
struct NestedOption {
|
||||
values: Vec<Option<String>>,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `Option<T>` must appear directly as the DTO field type
|
||||
--> tests/ui/nested_option.rs:5:13
|
||||
|
|
||||
5 | values: Vec<Option<String>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
Reference in New Issue
Block a user