Skip to content

Commit ab23399

Browse files
authored
Remove some dead code (#3189)
# Description of Changes This obscured other used code, so let's remove it as its dead. # API and ABI breaking changes None # Expected complexity level and risk -1 # Testing Not applicable.
1 parent b6fdc6c commit ab23399

File tree

2 files changed

+2
-79
lines changed

2 files changed

+2
-79
lines changed

crates/lib/src/lib.rs

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::db::raw_def::v9::RawModuleDefV9Builder;
22
use crate::db::raw_def::RawTableDefV8;
33
use anyhow::Context;
44
use sats::typespace::TypespaceBuilder;
5-
use spacetimedb_sats::{impl_serialize, WithTypespace};
5+
use spacetimedb_sats::WithTypespace;
66
use std::any::TypeId;
77
use std::collections::{btree_map, BTreeMap};
88

@@ -126,68 +126,6 @@ pub struct ReducerDef {
126126
pub args: Vec<ProductTypeElement>,
127127
}
128128

129-
impl ReducerDef {
130-
pub fn encode(&self, writer: &mut impl buffer::BufWriter) {
131-
bsatn::to_writer(writer, self).unwrap()
132-
}
133-
134-
pub fn serialize_args<'a>(ty: sats::WithTypespace<'a, Self>, value: &'a ProductValue) -> impl ser::Serialize + 'a {
135-
ReducerArgsWithSchema { value, ty }
136-
}
137-
138-
pub fn deserialize(
139-
ty: sats::WithTypespace<'_, Self>,
140-
) -> impl for<'de> de::DeserializeSeed<'de, Output = ProductValue> + '_ {
141-
ReducerDeserialize(ty)
142-
}
143-
}
144-
145-
struct ReducerDeserialize<'a>(sats::WithTypespace<'a, ReducerDef>);
146-
147-
impl<'de> de::DeserializeSeed<'de> for ReducerDeserialize<'_> {
148-
type Output = ProductValue;
149-
150-
fn deserialize<D: de::Deserializer<'de>>(self, deserializer: D) -> Result<Self::Output, D::Error> {
151-
deserializer.deserialize_product(self)
152-
}
153-
}
154-
155-
impl<'de> de::ProductVisitor<'de> for ReducerDeserialize<'_> {
156-
type Output = ProductValue;
157-
158-
fn product_name(&self) -> Option<&str> {
159-
Some(&self.0.ty().name)
160-
}
161-
fn product_len(&self) -> usize {
162-
self.0.ty().args.len()
163-
}
164-
fn product_kind(&self) -> de::ProductKind {
165-
de::ProductKind::ReducerArgs
166-
}
167-
168-
fn visit_seq_product<A: de::SeqProductAccess<'de>>(self, tup: A) -> Result<Self::Output, A::Error> {
169-
de::visit_seq_product(self.0.map(|r| &*r.args), &self, tup)
170-
}
171-
172-
fn visit_named_product<A: de::NamedProductAccess<'de>>(self, tup: A) -> Result<Self::Output, A::Error> {
173-
de::visit_named_product(self.0.map(|r| &*r.args), &self, tup)
174-
}
175-
}
176-
177-
struct ReducerArgsWithSchema<'a> {
178-
value: &'a ProductValue,
179-
ty: sats::WithTypespace<'a, ReducerDef>,
180-
}
181-
impl_serialize!([] ReducerArgsWithSchema<'_>, (self, ser) => {
182-
use itertools::Itertools;
183-
use ser::SerializeSeqProduct;
184-
let mut seq = ser.serialize_seq_product(self.value.elements.len())?;
185-
for (value, elem) in self.value.elements.iter().zip_eq(&self.ty.ty().args) {
186-
seq.serialize_element(&self.ty.with(&elem.algebraic_type).with_value(value))?;
187-
}
188-
seq.end()
189-
});
190-
191129
//WARNING: Change this structure (or any of their members) is an ABI change.
192130
#[derive(Debug, Clone, Default, SpacetimeType)]
193131
#[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))]

crates/schema/src/def/deserialize.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Helpers to allow deserializing data using a ReducerDef.
22
33
use crate::def::ReducerDef;
4-
use spacetimedb_lib::sats::{self, de, ser, ProductValue};
5-
use spacetimedb_sats::impl_serialize;
4+
use spacetimedb_lib::sats::{self, de, ProductValue};
65

76
/// Wrapper around a `ReducerDef` that allows deserializing to a `ProductValue` at the type
87
/// of the reducer's parameter `ProductType`.
@@ -45,17 +44,3 @@ impl<'de> de::ProductVisitor<'de> for ReducerArgsDeserializeSeed<'_> {
4544
de::visit_named_product(self.0.map(|r| &*r.params.elements), &self, tup)
4645
}
4746
}
48-
49-
pub struct ReducerArgsWithSchema<'a> {
50-
value: &'a ProductValue,
51-
ty: sats::WithTypespace<'a, ReducerDef>,
52-
}
53-
impl_serialize!([] ReducerArgsWithSchema<'_>, (self, ser) => {
54-
use itertools::Itertools;
55-
use ser::SerializeSeqProduct;
56-
let mut seq = ser.serialize_seq_product(self.value.elements.len())?;
57-
for (value, elem) in self.value.elements.iter().zip_eq(&*self.ty.ty().params.elements) {
58-
seq.serialize_element(&self.ty.with(&elem.algebraic_type).with_value(value))?;
59-
}
60-
seq.end()
61-
});

0 commit comments

Comments
 (0)