Skip to content

Commit

Permalink
Make usize byte serialisation platform-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
printfn committed Mar 16, 2024
1 parent cfc3ea1 commit 8417c59
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 1 addition & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ impl Context {

/// Serializes all variables defined in this context to a stream of bytes.
/// Note that the specific format is NOT stable, and can change with any
/// minor update. It is also not compatible between 32-bit and
/// 64-bit architectures.
/// minor update.
///
/// # Errors
/// This function returns an error if the input cannot be serialized.
Expand Down
15 changes: 14 additions & 1 deletion core/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ macro_rules! impl_serde {
};
}

impl_serde!(u8 i32 u64 usize);
impl_serde!(u8 i32 u64);

impl Serialize for usize {
fn serialize(&self, write: &mut impl io::Write) -> FResult<()> {
(*self as u64).serialize(write)
}
}

impl Deserialize for usize {
fn deserialize(read: &mut impl io::Read) -> FResult<Self> {
let val = u64::deserialize(read)?;
Self::try_from(val).map_err(|_| FendError::DeserializationError)
}
}

impl Serialize for &str {
fn serialize(&self, write: &mut impl io::Write) -> FResult<()> {
Expand Down
7 changes: 0 additions & 7 deletions windows-wix/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
limitations under the License.
-->

<!--
Please do not remove these pre-processor If-Else blocks. These are used with
the `cargo wix` subcommand to automatically determine the installation
destination for 32-bit versus 64-bit installers. Removal of these lines will
cause installation errors.
-->

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">

<Package Name="fend" UpgradeCode="2E3C8164-E07C-4B26-82B2-C5613FE8AD8F" Manufacturer="printfn"
Expand Down

0 comments on commit 8417c59

Please sign in to comment.