mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: config feature flag in lib-dispatch
This commit is contained in:
@ -22,8 +22,8 @@ thread-id = "3.3.0"
|
|||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
dyn-clone = "1.0"
|
dyn-clone = "1.0"
|
||||||
derivative = "2.2.0"
|
derivative = "2.2.0"
|
||||||
serde_json = {version = "1.0"}
|
serde_json = {version = "1.0", optional = true }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
dashmap = "5"
|
dashmap = "5"
|
||||||
|
|
||||||
#optional crate
|
#optional crate
|
||||||
@ -37,5 +37,5 @@ futures-util = "0.3.15"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["use_protobuf"]
|
default = ["use_protobuf"]
|
||||||
use_serde = ["bincode"]
|
use_serde = ["bincode", "serde_json", "serde"]
|
||||||
use_protobuf= ["protobuf"]
|
use_protobuf= ["protobuf"]
|
||||||
|
@ -6,7 +6,6 @@ use crate::{
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use dyn_clone::DynClone;
|
use dyn_clone::DynClone;
|
||||||
|
|
||||||
use serde::{Serialize, Serializer};
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use tokio::{sync::mpsc::error::SendError, task::JoinError};
|
use tokio::{sync::mpsc::error::SendError, task::JoinError};
|
||||||
|
|
||||||
@ -86,11 +85,11 @@ impl From<DispatchError> for EventResponse {
|
|||||||
err.inner_error().as_response()
|
err.inner_error().as_response()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "use_serde")]
|
||||||
impl Serialize for DispatchError {
|
impl serde::Serialize for DispatchError {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<<S as serde::Serializer>::Ok, <S as serde::Serializer>::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
serializer.serialize_str(&format!("{}", self))
|
serializer.serialize_str(&format!("{}", self))
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ use std::{fmt, fmt::Formatter};
|
|||||||
pub enum PayloadError {}
|
pub enum PayloadError {}
|
||||||
|
|
||||||
// TODO: support stream data
|
// TODO: support stream data
|
||||||
#[derive(Clone, serde::Serialize)]
|
#[derive(Clone)]
|
||||||
|
#[cfg_attr(feature = "user_serde", derive(serde::Serialize))]
|
||||||
pub enum Payload {
|
pub enum Payload {
|
||||||
None,
|
None,
|
||||||
Bytes(Bytes),
|
Bytes(Bytes),
|
||||||
|
@ -8,7 +8,8 @@ use crate::{
|
|||||||
use derivative::*;
|
use derivative::*;
|
||||||
use std::{convert::TryFrom, fmt, fmt::Formatter};
|
use std::{convert::TryFrom, fmt, fmt::Formatter};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "user_serde", derive(serde::Serialize))]
|
||||||
pub enum StatusCode {
|
pub enum StatusCode {
|
||||||
Ok = 0,
|
Ok = 0,
|
||||||
Err = 1,
|
Err = 1,
|
||||||
@ -16,7 +17,8 @@ pub enum StatusCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// serde user guide: https://serde.rs/field-attrs.html
|
// serde user guide: https://serde.rs/field-attrs.html
|
||||||
#[derive(Debug, Clone, serde::Serialize, Derivative)]
|
#[derive(Debug, Clone, Derivative)]
|
||||||
|
#[cfg_attr(feature = "user_serde", derive(serde::Serialize))]
|
||||||
pub struct EventResponse {
|
pub struct EventResponse {
|
||||||
#[derivative(Debug = "ignore")]
|
#[derivative(Debug = "ignore")]
|
||||||
pub payload: Payload,
|
pub payload: Payload,
|
||||||
|
Reference in New Issue
Block a user