@@ -1,8 +1,9 @@
|
||||
[service]
|
||||
service = "my-service"
|
||||
domain = "my-domain"
|
||||
service = "basic-setup"
|
||||
domain = "examples"
|
||||
codegen = ["rust"]
|
||||
|
||||
[[publish]]
|
||||
[[publish]]
|
||||
schema-path = "schemas/crunch"
|
||||
output-path = "src/gencrunch"
|
||||
entities = ["example"]
|
7
examples/basic-setup/schemas/crunch/example.proto
Normal file
7
examples/basic-setup/schemas/crunch/example.proto
Normal file
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package examples.example;
|
||||
|
||||
message MyEvent {
|
||||
string my_field = 1;
|
||||
}
|
6
examples/basic-setup/src/gencrunch/examples.example.rs
Normal file
6
examples/basic-setup/src/gencrunch/examples.example.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct MyEvent {
|
||||
#[prost(string, tag = "1")]
|
||||
pub my_field: ::prost::alloc::string::String,
|
||||
}
|
@@ -1,26 +1,54 @@
|
||||
pub mod basic {
|
||||
pub mod includes {
|
||||
pub mod my_include {
|
||||
use prost::Message;
|
||||
include!("basic.includes.my_include.rs");
|
||||
pub mod root {
|
||||
pub mod basic {
|
||||
pub mod includes {
|
||||
pub mod my_include {
|
||||
use prost::Message;
|
||||
include!("basic.includes.my_include.rs");
|
||||
impl ::crunch::traits::Serializer for MyInclude {
|
||||
fn serialize(&self) -> Result<Vec<u8>, ::crunch::errors::SerializeError> {
|
||||
Ok(self.encode_to_vec())
|
||||
}
|
||||
}
|
||||
impl ::crunch::traits::Deserializer for MyInclude {
|
||||
fn deserialize(raw: Vec<u8>) -> Result<Self, ::crunch::errors::DeserializeError>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let output = Self::decode(raw.as_slice()).map_err(|e| ::crunch::errors::DeserializeError::ProtoErr(e))?;
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::crunch::traits::Serializer for MyInclude {
|
||||
impl crunch::traits::Event for MyInclude {
|
||||
fn event_info() -> ::crunch::traits::EventInfo {
|
||||
::crunch::traits::EventInfo {
|
||||
domain: "my-domain",
|
||||
entity_type: "my-entity-type",
|
||||
event_name: "my-event-name",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub mod my_event {
|
||||
use prost::Message;
|
||||
include!("basic.my_event.rs");
|
||||
impl ::crunch::traits::Serializer for MyEvent {
|
||||
fn serialize(&self) -> Result<Vec<u8>, ::crunch::errors::SerializeError> {
|
||||
Ok(self.encode_to_vec())
|
||||
}
|
||||
}
|
||||
impl ::crunch::traits::Deserializer for MyInclude {
|
||||
impl ::crunch::traits::Deserializer for MyEvent {
|
||||
fn deserialize(raw: Vec<u8>) -> Result<Self, ::crunch::errors::DeserializeError>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let output = Self::decode(raw.as_slice())
|
||||
.map_err(::crunch::errors::DeserializeError::ProtoErr)?;
|
||||
let output = Self::decode(raw.as_slice()).map_err(|e| ::crunch::errors::DeserializeError::ProtoErr(e))?;
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
impl crunch::traits::Event for MyInclude {
|
||||
impl crunch::traits::Event for MyEvent {
|
||||
fn event_info() -> ::crunch::traits::EventInfo {
|
||||
::crunch::traits::EventInfo {
|
||||
domain: "my-domain",
|
||||
@@ -31,32 +59,32 @@ pub mod basic {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub mod my_event {
|
||||
use prost::Message;
|
||||
include!("basic.my_event.rs");
|
||||
|
||||
impl ::crunch::traits::Serializer for MyEvent {
|
||||
fn serialize(&self) -> Result<Vec<u8>, ::crunch::errors::SerializeError> {
|
||||
Ok(self.encode_to_vec())
|
||||
pub mod examples {
|
||||
pub mod example {
|
||||
use prost::Message;
|
||||
include!("examples.example.rs");
|
||||
impl ::crunch::traits::Serializer for MyEvent {
|
||||
fn serialize(&self) -> Result<Vec<u8>, ::crunch::errors::SerializeError> {
|
||||
Ok(self.encode_to_vec())
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ::crunch::traits::Deserializer for MyEvent {
|
||||
fn deserialize(raw: Vec<u8>) -> Result<Self, ::crunch::errors::DeserializeError>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let output = Self::decode(raw.as_slice())
|
||||
.map_err(::crunch::errors::DeserializeError::ProtoErr)?;
|
||||
Ok(output)
|
||||
impl ::crunch::traits::Deserializer for MyEvent {
|
||||
fn deserialize(raw: Vec<u8>) -> Result<Self, ::crunch::errors::DeserializeError>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let output = Self::decode(raw.as_slice()).map_err(|e| ::crunch::errors::DeserializeError::ProtoErr(e))?;
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl crunch::traits::Event for MyEvent {
|
||||
fn event_info() -> ::crunch::traits::EventInfo {
|
||||
::crunch::traits::EventInfo {
|
||||
domain: "my-domain",
|
||||
entity_type: "my-entity-type",
|
||||
event_name: "my-event-name",
|
||||
impl crunch::traits::Event for MyEvent {
|
||||
fn event_info() -> ::crunch::traits::EventInfo {
|
||||
::crunch::traits::EventInfo {
|
||||
domain: "my-domain",
|
||||
entity_type: "my-entity-type",
|
||||
event_name: "my-event-name",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user