apache_dubbo/
lib.rs

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18pub mod codegen;
19pub mod common;
20mod framework;
21pub mod invocation;
22pub mod protocol;
23pub mod registry;
24pub mod status;
25pub mod triple;
26pub mod utils;
27
28use http_body::Body;
29use std::future::Future;
30use std::pin::Pin;
31
32pub use framework::Dubbo;
33
34pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
35pub type BoxFuture<T, E> = self::Pin<Box<dyn self::Future<Output = Result<T, E>> + Send + 'static>>;
36pub(crate) type Error = Box<dyn std::error::Error + Send + Sync>;
37pub type BoxBody = http_body::combinators::UnsyncBoxBody<bytes::Bytes, self::status::Status>;
38
39pub fn empty_body() -> BoxBody {
40    http_body::Empty::new()
41        .map_err(|err| match err {})
42        .boxed_unsync()
43}
44
45pub(crate) fn boxed<B>(body: B) -> BoxBody
46where
47    B: http_body::Body<Data = bytes::Bytes> + Send + 'static,
48    B::Error: Into<self::Error>,
49{
50    body.map_err(|err| {
51        self::status::Status::new(self::status::Code::Internal, format!("{:?}", err.into()))
52    })
53    .boxed_unsync()
54}