-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements writing FlexSym annotation sequences (#711)
* Moves annotation delegating macro to a central location * Removes vestigial copy of the 1.0 binary writer impl * Implements writing FlexSym annotation sequences
- Loading branch information
Showing
4 changed files
with
307 additions
and
1,018 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,21 @@ | ||
pub mod v1_0; | ||
pub mod v1_1; | ||
|
||
/// Takes a series of `TYPE => METHOD` pairs, generating a function for each that calls the host | ||
/// type's `encode_annotated` method to encode an annotations sequence and then delegates encoding | ||
/// the value to the corresponding value writer method. | ||
// This macro is used in the v1_0 and v1_1 binary writer implementations, which both define an | ||
// `encode_annotated` method. That method is not codified (for example: in a trait); this relies | ||
// solely on convention between the two. | ||
macro_rules! annotate_and_delegate { | ||
// End of iteration | ||
() => {}; | ||
// Recurses one argument pair at a time | ||
($value_type:ty => $method:ident, $($rest:tt)*) => { | ||
fn $method(self, value: $value_type) -> IonResult<()> { | ||
self.encode_annotated(|value_writer| value_writer.$method(value)) | ||
} | ||
annotate_and_delegate!($($rest)*); | ||
}; | ||
} | ||
pub(crate) use annotate_and_delegate; |
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
Oops, something went wrong.