mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix clippy warnings
This commit is contained in:
@ -53,7 +53,7 @@ where
|
||||
T: std::convert::TryFrom<Bytes, Error = protobuf::ProtobufError>,
|
||||
{
|
||||
fn parse_from_bytes(bytes: Bytes) -> Result<Self, DispatchError> {
|
||||
let data = T::try_from(bytes.clone())?;
|
||||
let data = T::try_from(bytes)?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ where
|
||||
T: FromBytes,
|
||||
{
|
||||
match payload {
|
||||
Payload::None => Err(InternalError::UnexpectedNone(format!("Parse fail, expected payload")).into()),
|
||||
Payload::None => Err(InternalError::UnexpectedNone("Parse fail, expected payload".to_string()).into()),
|
||||
Payload::Bytes(bytes) => {
|
||||
let data = T::parse_from_bytes(bytes.clone())?;
|
||||
Ok(Data(data))
|
||||
|
@ -26,8 +26,7 @@ impl EventDispatch {
|
||||
tracing::trace!("{}", module_info(&modules));
|
||||
let module_map = as_module_map(modules);
|
||||
|
||||
let dispatch = EventDispatch { module_map, runtime };
|
||||
dispatch
|
||||
EventDispatch { module_map, runtime }
|
||||
}
|
||||
|
||||
pub fn async_send<Req>(dispatch: Arc<EventDispatch>, request: Req) -> DispatchFuture<EventResponse>
|
||||
@ -99,9 +98,7 @@ where
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.as_mut().project();
|
||||
loop {
|
||||
return Poll::Ready(futures_core::ready!(this.fut.poll(cx)));
|
||||
}
|
||||
Poll::Ready(futures_core::ready!(this.fut.poll(cx)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +165,7 @@ impl Service<DispatchContext> for DispatchService {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn module_info(modules: &Vec<Module>) -> String {
|
||||
fn module_info(modules: &[Module]) -> String {
|
||||
let mut info = format!("{} modules loaded\n", modules.len());
|
||||
for module in modules {
|
||||
info.push_str(&format!("-> {} loaded \n", module.name));
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::module_inception)]
|
||||
mod errors;
|
||||
|
||||
pub use errors::*;
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::module_inception)]
|
||||
pub use container::*;
|
||||
pub use data::*;
|
||||
pub use module::*;
|
||||
|
@ -59,14 +59,18 @@ pub struct Module {
|
||||
service_map: Arc<HashMap<Event, EventServiceFactory>>,
|
||||
}
|
||||
|
||||
impl Module {
|
||||
pub fn new() -> Self {
|
||||
impl std::default::Default for Module {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: "".to_owned(),
|
||||
module_data: Arc::new(ModuleDataMap::new()),
|
||||
service_map: Arc::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Module {
|
||||
pub fn new() -> Self { Module::default() }
|
||||
|
||||
pub fn name(mut self, s: &str) -> Self {
|
||||
self.name = s.to_owned();
|
||||
@ -99,7 +103,7 @@ impl Module {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn events(&self) -> Vec<Event> { self.service_map.keys().map(|key| key.clone()).collect::<Vec<_>>() }
|
||||
pub fn events(&self) -> Vec<Event> { self.service_map.keys().cloned().collect::<Vec<_>>() }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -168,7 +172,7 @@ impl Service<ModuleRequest> for ModuleService {
|
||||
fn call(&self, request: ModuleRequest) -> Self::Future {
|
||||
let ModuleRequest { id, event, payload } = request;
|
||||
let module_data = self.module_data.clone();
|
||||
let request = EventRequest::new(id.clone(), event, module_data);
|
||||
let request = EventRequest::new(id, event, module_data);
|
||||
|
||||
match self.service_map.get(&request.event) {
|
||||
Some(factory) => {
|
||||
@ -200,10 +204,8 @@ impl Future for ModuleServiceFuture {
|
||||
type Output = Result<EventResponse, DispatchError>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
loop {
|
||||
let (_, response) = ready!(self.as_mut().project().fut.poll(cx))?.into_parts();
|
||||
return Poll::Ready(Ok(response));
|
||||
}
|
||||
let (_, response) = ready!(self.as_mut().project().fut.poll(cx))?.into_parts();
|
||||
Poll::Ready(Ok(response))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::module_inception)]
|
||||
pub mod payload;
|
||||
mod request;
|
||||
|
||||
|
@ -25,26 +25,25 @@ fn format_payload_print(payload: &Payload, f: &mut Formatter<'_>) -> fmt::Result
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::Into<Payload> for String {
|
||||
fn into(self) -> Payload { Payload::Bytes(Bytes::from(self)) }
|
||||
impl std::convert::From<String> for Payload {
|
||||
fn from(s: String) -> Self { Payload::Bytes(Bytes::from(s)) }
|
||||
}
|
||||
|
||||
impl std::convert::Into<Payload> for &'_ String {
|
||||
fn into(self) -> Payload { Payload::Bytes(Bytes::from(self.to_owned())) }
|
||||
impl std::convert::From<&'_ String> for Payload {
|
||||
fn from(s: &String) -> Self { Payload::Bytes(Bytes::from(s.to_owned())) }
|
||||
}
|
||||
|
||||
impl std::convert::Into<Payload> for Bytes {
|
||||
fn into(self) -> Payload { Payload::Bytes(self) }
|
||||
impl std::convert::From<Bytes> for Payload {
|
||||
fn from(bytes: Bytes) -> Self { Payload::Bytes(bytes) }
|
||||
}
|
||||
|
||||
impl std::convert::Into<Payload> for () {
|
||||
fn into(self) -> Payload { Payload::None }
|
||||
impl std::convert::From<()> for Payload {
|
||||
fn from(_: ()) -> Self { Payload::None }
|
||||
}
|
||||
impl std::convert::From<Vec<u8>> for Payload {
|
||||
fn from(bytes: Vec<u8>) -> Self { Payload::Bytes(Bytes::from(bytes)) }
|
||||
}
|
||||
|
||||
impl std::convert::Into<Payload> for Vec<u8> {
|
||||
fn into(self) -> Payload { Payload::Bytes(Bytes::from(self)) }
|
||||
}
|
||||
|
||||
impl std::convert::Into<Payload> for &str {
|
||||
fn into(self) -> Payload { self.to_string().into() }
|
||||
impl std::convert::From<&str> for Payload {
|
||||
fn from(s: &str) -> Self { s.to_string().into() }
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::module_inception)]
|
||||
pub use builder::*;
|
||||
pub use responder::*;
|
||||
pub use response::*;
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::module_inception)]
|
||||
mod boxed;
|
||||
mod handler;
|
||||
mod service;
|
||||
|
@ -40,12 +40,11 @@ impl FlowySystem {
|
||||
});
|
||||
|
||||
let module_map = as_module_map(module_factory());
|
||||
sender_factory(module_map.clone(), &runtime);
|
||||
sender_factory(module_map, &runtime);
|
||||
|
||||
let system = Self { sys_cmd_tx };
|
||||
FlowySystem::set_current(system);
|
||||
let runner = SystemRunner { rt: runtime, stop_rx };
|
||||
runner
|
||||
SystemRunner { rt: runtime, stop_rx }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::{io, thread};
|
||||
use thread_id;
|
||||
|
||||
use tokio::runtime;
|
||||
|
||||
pub mod ready;
|
||||
|
Reference in New Issue
Block a user