mesh_rpc/
rpc.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use crate::service::Code;
5use crate::service::Status;
6use thiserror::Error;
7
8pub fn status_from_err(code: Code, err: impl Into<anyhow::Error>) -> Status {
9    Status {
10        code: code as i32,
11        message: format!("{:#}", err.into()),
12        details: Vec::new(),
13    }
14}
15
16#[derive(Debug, Error)]
17pub enum ProtocolError {
18    #[error("invalid message type {0}")]
19    InvalidMessageType(u8),
20    #[error("stream id must be odd for client requests")]
21    EvenStreamId,
22}