Skip to content

Conversation

muhamadazmy
Copy link
Contributor

@muhamadazmy muhamadazmy commented Apr 30, 2025

introduce BilrostAs derive macro

Summary:
The macro can be deriven on anytime given that the target type
can be created From<&T>.

There is also an implementation for an adaptor that can use the
Display and FromStr to serialize and deserialize the type.

Notice:

Right now the BilrostAs macro requires that the annotated type must
implement Default. This is needed since Bilrost requires that it
can create an empty state of that field.


Stack created with Sapling. Best reviewed with ReviewStack.

@muhamadazmy
Copy link
Contributor Author

@AhmedSoliman I recommend that you look at the tests here https://github.com/restatedev/restate/pull/3208/files#diff-84254cab3a4d09daad7bfb0f2f851bec0b3151449b5a620fb49df41878ed216f first to see how the macro is used


Err(syn::Error::new(
input.span(),
"Missing bilrost_as attribute",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth including usage example to help the user.

@muhamadazmy
Copy link
Contributor Author

@AhmedSoliman

The BilrostDto traits are completely gone. Root messages now must derive bilrost::Message. For any field in the message that is not bilrost compatible, it must use the BirlostAs macro.

@muhamadazmy muhamadazmy requested a review from AhmedSoliman May 2, 2025 09:27
Copy link
Contributor

@AhmedSoliman AhmedSoliman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superb!

@@ -90,6 +94,9 @@ where
}

impl<V> NetSerde for HashSet<V> where V: NetSerde {}
impl<Idx> NetSerde for RangeInclusive<Idx> where Idx: NetSerde {}
impl<T> NetSerde for Arc<T> where T: NetSerde {}
impl<T> NetSerde for Arc<[T]> where T: NetSerde {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we also have Box<[T]>?

Summary:
The macro can be deriven on anytime given that the target type
can be created From<&T>.

There is also an implementation for an adaptor that can use the
`Display` and `FromStr` to serialize and deserialize the type.

## Notice:
Right now the BilrostAs macro requires that the annotated type must
implement `Default`. This is needed since Bilrost requires that it
can create an `empty state` of that field.
@muhamadazmy muhamadazmy merged commit 36900b7 into restatedev:main May 2, 2025
59 of 60 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2025
@muhamadazmy muhamadazmy deleted the pr3208 branch May 2, 2025 19:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants