Skip to content

Commit 88a1379

Browse files
committed
Removed Decoder type from Patch trait
1 parent 4fb3de5 commit 88a1379

File tree

6 files changed

+7
-21
lines changed

6 files changed

+7
-21
lines changed

rorm-macro-impl/src/generate/patch.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::array;
22

3-
use proc_macro2::{Ident, Span, TokenStream};
3+
use proc_macro2::{Ident, TokenStream};
44
use quote::{format_ident, quote, ToTokens};
5-
use syn::{Generics, LitStr, Type, Visibility};
5+
use syn::{Generics, Type, Visibility};
66

77
use crate::parse::patch::ParsedPatch;
88
use crate::MacroConfig;
@@ -71,10 +71,6 @@ pub fn partially_generate_patch<'a>(
7171
let value_space_marker_impl = format_ident!("__{patch}_ValueSpaceImplMarker");
7272

7373
let decoder = format_ident!("__{patch}_Decoder");
74-
let decoder_doc = LitStr::new(
75-
&format!("[`Decoder`]({rorm_path}::crud::decoder::Decoder) for [`{patch}`]",),
76-
Span::call_site(),
77-
);
7874

7975
let [fields_1, fields_2, fields_3, fields_4, fields_5, fields_6, fields_7] =
8076
array::from_fn(|_| fields.clone());
@@ -105,7 +101,7 @@ pub fn partially_generate_patch<'a>(
105101
}
106102
#vis use #value_space_impl::*;
107103

108-
#[doc = #decoder_doc]
104+
#[doc(hidden)]
109105
#vis struct #decoder #impl_generics #where_clause {
110106
#(
111107
#fields_1: <#types as #rorm_path::fields::traits::FieldType>::Decoder,
@@ -151,8 +147,6 @@ pub fn partially_generate_patch<'a>(
151147

152148
type ValueSpaceImpl = #value_space_impl #type_generics;
153149

154-
type Decoder = #decoder #type_generics;
155-
156150
fn push_columns(columns: &mut Vec<&'static str>) {#(
157151
columns.extend(
158152
#rorm_path::fields::proxy::columns(|| <<Self as #rorm_path::model::Patch>::Model as #rorm_path::model::Model>::FIELDS.#fields_5)

src/model.rs

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use rorm_declaration::imr;
44

55
use crate::conditions::{Binary, BinaryOperator, Column, Value};
6-
use crate::crud::decoder::Decoder;
76
use crate::crud::selector::Selector;
87
use crate::fields::proxy;
98
use crate::internal::field::{Field, SingleColumnField};
@@ -22,9 +21,6 @@ pub trait Patch: Sized + 'static {
2221
/// This is more of an implementation detail of the derive macro.
2322
type ValueSpaceImpl: Selector<Result = Self, Model = Self::Model> + Default;
2423

25-
/// [`Decoder`] returned by [`Patch::select`] which decodes this patch from a row
26-
type Decoder: Decoder<Result = Self>;
27-
2824
/// Create a `Vec` containing the patch's columns
2925
fn columns() -> Vec<&'static str> {
3026
let mut columns = Vec::new();

tests/data/derives/basic_expansions/BasicModel.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub enum __BasicModel_ValueSpaceImpl {
8686
__BasicModel_ValueSpaceImplMarker(::std::marker::PhantomData<BasicModel>),
8787
}
8888
pub use __BasicModel_ValueSpaceImpl::*;
89-
///[`Decoder`](:: rorm::crud::decoder::Decoder) for [`BasicModel`]
89+
#[doc(hidden)]
9090
pub struct __BasicModel_Decoder {
9191
id: <i64 as ::rorm::fields::traits::FieldType>::Decoder,
9292
}
@@ -131,7 +131,6 @@ impl ::rorm::crud::decoder::Decoder for __BasicModel_Decoder {
131131
impl ::rorm::model::Patch for BasicModel {
132132
type Model = BasicModel;
133133
type ValueSpaceImpl = __BasicModel_ValueSpaceImpl;
134-
type Decoder = __BasicModel_Decoder;
135134
fn push_columns(columns: &mut Vec<&'static str>) {
136135
columns
137136
.extend(

tests/data/derives/basic_expansions/BasicPatch.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub enum __BasicPatch_ValueSpaceImpl {
77
__BasicPatch_ValueSpaceImplMarker(::std::marker::PhantomData<BasicPatch>),
88
}
99
pub use __BasicPatch_ValueSpaceImpl::*;
10-
///[`Decoder`](:: rorm::crud::decoder::Decoder) for [`BasicPatch`]
10+
#[doc(hidden)]
1111
pub struct __BasicPatch_Decoder {}
1212
impl ::rorm::crud::selector::Selector for __BasicPatch_ValueSpaceImpl {
1313
type Result = BasicPatch;
@@ -44,7 +44,6 @@ impl ::rorm::crud::decoder::Decoder for __BasicPatch_Decoder {
4444
impl ::rorm::model::Patch for BasicPatch {
4545
type Model = BasicModel;
4646
type ValueSpaceImpl = __BasicPatch_ValueSpaceImpl;
47-
type Decoder = __BasicPatch_Decoder;
4847
fn push_columns(columns: &mut Vec<&'static str>) {}
4948
fn push_references<'a>(&'a self, values: &mut Vec<::rorm::conditions::Value<'a>>) {}
5049
fn push_values(self, values: &mut Vec<::rorm::conditions::Value>) {}

tests/data/derives/experimental_expansions/Generic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub enum __Generic_ValueSpaceImpl<X: rorm::fields::traits::FieldType> {
136136
__Generic_ValueSpaceImplMarker(::std::marker::PhantomData<Generic<X>>),
137137
}
138138
pub use __Generic_ValueSpaceImpl::*;
139-
///[`Decoder`](:: rorm::crud::decoder::Decoder) for [`Generic`]
139+
#[doc(hidden)]
140140
pub struct __Generic_Decoder<X: rorm::fields::traits::FieldType> {
141141
id: <i64 as ::rorm::fields::traits::FieldType>::Decoder,
142142
x: <X as ::rorm::fields::traits::FieldType>::Decoder,
@@ -188,7 +188,6 @@ for __Generic_Decoder<X> {
188188
impl<X: rorm::fields::traits::FieldType> ::rorm::model::Patch for Generic<X> {
189189
type Model = Generic<X>;
190190
type ValueSpaceImpl = __Generic_ValueSpaceImpl<X>;
191-
type Decoder = __Generic_Decoder<X>;
192191
fn push_columns(columns: &mut Vec<&'static str>) {
193192
columns
194193
.extend(

tests/data/derives/experimental_expansions/Unregistered.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub enum __Unregistered_ValueSpaceImpl {
8181
__Unregistered_ValueSpaceImplMarker(::std::marker::PhantomData<Unregistered>),
8282
}
8383
pub use __Unregistered_ValueSpaceImpl::*;
84-
///[`Decoder`](:: rorm::crud::decoder::Decoder) for [`Unregistered`]
84+
#[doc(hidden)]
8585
pub struct __Unregistered_Decoder {
8686
id: <i64 as ::rorm::fields::traits::FieldType>::Decoder,
8787
}
@@ -126,7 +126,6 @@ impl ::rorm::crud::decoder::Decoder for __Unregistered_Decoder {
126126
impl ::rorm::model::Patch for Unregistered {
127127
type Model = Unregistered;
128128
type ValueSpaceImpl = __Unregistered_ValueSpaceImpl;
129-
type Decoder = __Unregistered_Decoder;
130129
fn push_columns(columns: &mut Vec<&'static str>) {
131130
columns
132131
.extend(

0 commit comments

Comments
 (0)