From c286708bff7e3921d20a589befe74f3689595a19 Mon Sep 17 00:00:00 2001 From: Avril Date: Tue, 3 Aug 2021 16:49:27 +0100 Subject: [PATCH] Start: `UntypedMessageValue` for unsafe casting of `SerializedMessage`s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for rsh's current commit: Half blessing − 半吉 --- src/message.rs | 1 - src/message/value.rs | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/message.rs b/src/message.rs index 5c3f400..3be60c2 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,7 +1,6 @@ //! Messages use super::*; use std::marker::PhantomData; -use serde::{Serialize, Deserialize}; use cryptohelpers::{ sha256, aes, diff --git a/src/message/value.rs b/src/message/value.rs index 536d157..33d3632 100644 --- a/src/message/value.rs +++ b/src/message/value.rs @@ -1,5 +1,6 @@ //! Message values use super::*; +use serde::{Serialize, Deserialize}; /// A value that can be used for messages. pub trait MessageValue: Serialize + for<'de> Deserialize<'de>{} @@ -24,3 +25,9 @@ pub struct MessageValueAny(Box); //impl MessageValue for DynamicMessageValue //where T: Serialize + for<'de> Deserialize<'de> + Any{} */ + +/// A type-unsafe `MessageValue` that can be used to transmute `SerializedMessage` instances. +/// +/// This operation is unsafe and can result in deserializing the `SerializedMessage` failing, or even worse, a type confusion. +#[derive(Debug, Serialize, Deserialize)] +pub enum UntypedMessageValue{}