-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat(convert): add derive macros for To and FromBytes
- Loading branch information
Showing
12 changed files
with
270 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[test] | ||
fn ui() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/ui/*.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use extism_convert_macros::ToBytes; | ||
|
||
#[derive(ToBytes)] | ||
struct MissingEncoding; | ||
|
||
#[derive(ToBytes)] | ||
#[encoding] | ||
struct EmptyAttr; | ||
|
||
#[derive(ToBytes)] | ||
#[encoding = "string"] | ||
struct EqNoParen; | ||
|
||
#[derive(ToBytes)] | ||
#[encoding(something, else)] | ||
struct NotAPath; | ||
|
||
#[derive(ToBytes)] | ||
#[encoding(Multiple)] | ||
#[encoding(Encodings)] | ||
struct MultipleEncodings; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
error: encoding needs to be specified | ||
|
||
= try: `#[encoding(ToJson)]` | ||
--> tests/ui/invalid-encoding.rs:3:10 | ||
| | ||
3 | #[derive(ToBytes)] | ||
| ^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `ToBytes` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: expected attribute arguments in parentheses: #[encoding(...)] | ||
|
||
= note: expects a path | ||
= try: `#[encoding(ToJson)]` | ||
--> tests/ui/invalid-encoding.rs:7:3 | ||
| | ||
7 | #[encoding] | ||
| ^^^^^^^^ | ||
|
||
error: expected parentheses: #[encoding(...)] | ||
|
||
= note: expects a path | ||
= try: `#[encoding(ToJson)]` | ||
--> tests/ui/invalid-encoding.rs:11:12 | ||
| | ||
11 | #[encoding = "string"] | ||
| ^ | ||
|
||
error: unexpected token | ||
|
||
= note: expects a path | ||
= try: `#[encoding(ToJson)]` | ||
--> tests/ui/invalid-encoding.rs:15:21 | ||
| | ||
15 | #[encoding(something, else)] | ||
| ^ | ||
|
||
error: only one encoding can be specified | ||
|
||
= try: remove `#[encoding(Encodings)]` | ||
--> tests/ui/invalid-encoding.rs:20:1 | ||
| | ||
20 | #[encoding(Encodings)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
#[test] | ||
fn test() { | ||
use extism_convert::{Json, ToBytes}; | ||
use serde::Serialize; | ||
|
||
#[derive(ToBytes, Serialize)] | ||
#[encoding(Json)] | ||
struct Struct { | ||
hello: String, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters