Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/core/src/messages/control_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ pub struct NodeStatus {
#[repr(i32)]
pub enum HostType {
Wasm = 0,
Js,
Js = 1,
}
50 changes: 49 additions & 1 deletion crates/sats/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ mod impls;
pub mod serde;

use crate::{algebraic_value::ser::ValueSerializer, bsatn, buffer::BufWriter, AlgebraicType};
use core::fmt;
use core::marker::PhantomData;
use core::{convert::Infallible, fmt};
use ethnum::{i256, u256};
pub use spacetimedb_bindings_macro::Serialize;

Expand Down Expand Up @@ -385,3 +386,50 @@ impl<S: SerializeSeqProduct> SerializeNamedProduct for ForwardNamedToSeqProduct<
self.tup.end()
}
}

/// A type usable in one of the associated types of [`Serializer`]
/// when the data format does not support the data.
pub struct Impossible<Ok, Error> {
// They gave each other a pledge. Unheard of, absurd.
absurd: Infallible,
marker: PhantomData<(Ok, Error)>,
}

impl<Ok, Error: self::Error> SerializeArray for Impossible<Ok, Error> {
type Ok = Ok;
type Error = Error;

fn serialize_element<T: Serialize + ?Sized>(&mut self, _: &T) -> Result<(), Self::Error> {
match self.absurd {}
}

fn end(self) -> Result<Self::Ok, Self::Error> {
match self.absurd {}
}
}

impl<Ok, Error: self::Error> SerializeSeqProduct for Impossible<Ok, Error> {
type Ok = Ok;
type Error = Error;

fn serialize_element<T: Serialize + ?Sized>(&mut self, _: &T) -> Result<(), Self::Error> {
match self.absurd {}
}

fn end(self) -> Result<Self::Ok, Self::Error> {
match self.absurd {}
}
}

impl<Ok, Error: self::Error> SerializeNamedProduct for Impossible<Ok, Error> {
type Ok = Ok;
type Error = Error;

fn serialize_element<T: Serialize + ?Sized>(&mut self, _: Option<&str>, _: &T) -> Result<(), Self::Error> {
match self.absurd {}
}

fn end(self) -> Result<Self::Ok, Self::Error> {
match self.absurd {}
}
}
Loading