Skip to content

Commit 2f40add

Browse files
committed
[opentitanlib] rename proxy::errors to util::serializable_error
This is not specific to OT-proxy, and this move will make it possible to move OT proxy to its own crate. Signed-off-by: Gary Guo <[email protected]>
1 parent b479ed8 commit 2f40add

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

sw/host/opentitanlib/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ rust_library(
122122
"src/ownership/mod.rs",
123123
"src/ownership/owner.rs",
124124
"src/ownership/rescue.rs",
125-
"src/proxy/errors.rs",
126125
"src/proxy/handler.rs",
127126
"src/proxy/mod.rs",
128127
"src/proxy/nonblocking_uart.rs",
@@ -189,6 +188,7 @@ rust_library(
189188
"src/util/rom_detect.rs",
190189
"src/util/runtime.rs",
191190
"src/util/serde.rs",
191+
"src/util/serializable_error.rs",
192192
"src/util/status.rs",
193193
"src/util/testing.rs",
194194
"src/util/unknown.rs",

sw/host/opentitanlib/src/proxy/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::sync::{Arc, Mutex};
1111
use std::time::Duration;
1212

1313
use super::CommandHandler;
14-
use super::errors::SerializedError;
1514
use super::protocol::{
1615
BitbangEntryRequest, BitbangEntryResponse, DacBangEntryRequest, EmuRequest, EmuResponse,
1716
GpioBitRequest, GpioBitResponse, GpioDacRequest, GpioDacResponse, GpioMonRequest,
@@ -28,6 +27,7 @@ use crate::io::{i2c, spi};
2827
use crate::proxy::Connection;
2928
use crate::proxy::nonblocking_uart::NonblockingUartRegistry;
3029
use crate::transport::TransportError;
30+
use crate::util::serializable_error::SerializedError;
3131

3232
/// Implementation of the handling of each protocol request, by means of an underlying
3333
/// `Transport` implementation.

sw/host/opentitanlib/src/proxy/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use tokio::net::TcpListener;
1212

1313
use crate::app::TransportWrapper;
1414

15-
pub mod errors;
1615
mod handler;
1716
mod nonblocking_uart;
1817
pub mod protocol;

sw/host/opentitanlib/src/proxy/protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::io::gpio::{
1313
use crate::io::i2c::DeviceStatus;
1414
use crate::io::spi::{MaxSizes, TransferMode};
1515
use crate::io::uart::{FlowControl, Parity};
16-
use crate::proxy::errors::SerializedError;
1716
use crate::transport::Capabilities;
17+
use crate::util::serializable_error::SerializedError;
1818
use crate::util::voltage::Voltage;
1919

2020
#[derive(Serialize, Deserialize)]

sw/host/opentitanlib/src/util/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod raw_tty;
1616
pub mod rom_detect;
1717
pub mod runtime;
1818
pub mod serde;
19+
pub mod serializable_error;
1920
pub mod status;
2021
pub mod testing;
2122
pub mod unknown;

sw/host/opentitanlib/src/proxy/errors.rs renamed to sw/host/opentitanlib/src/util/serializable_error.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct SerializableErrorRegistration {
1414
inventory::collect!(SerializableErrorRegistration);
1515

1616
/// `SerializableError` is a trait which represents an error type that can
17-
/// be sent over the wire by the proxy protocol.
17+
/// be sent over the wire.
1818
#[typetag::serde(tag = "error_type")]
1919
pub trait SerializableError: Serialize + std::error::Error + std::fmt::Debug + Send + Sync {
2020
fn as_anyhow_error(self: Box<Self>) -> anyhow::Error;
@@ -27,14 +27,14 @@ macro_rules! impl_serializable_error {
2727
($t:ty) => {
2828
const _: () = {
2929
#[typetag::serde]
30-
impl $crate::proxy::errors::SerializableError for $t {
30+
impl $crate::util::serializable_error::SerializableError for $t {
3131
fn as_anyhow_error(self: Box<$t>) -> anyhow::Error {
3232
self.into()
3333
}
3434
}
3535

36-
$crate::proxy::errors::submit! {
37-
$crate::proxy::errors::SerializableErrorRegistration {
36+
$crate::util::serializable_error::submit! {
37+
$crate::util::serializable_error::SerializableErrorRegistration {
3838
try_convert: |err| {
3939
if !err.is::<$t>() {
4040
return Err(err);
@@ -43,7 +43,7 @@ macro_rules! impl_serializable_error {
4343
let description = err.to_string();
4444
let backtrace = format!("{:#?}", err.backtrace());
4545
let downcast = err.downcast::<$t>().unwrap();
46-
Ok($crate::proxy::errors::SerializedError {
46+
Ok($crate::util::serializable_error::SerializedError {
4747
description,
4848
backtrace,
4949
error: Some(Box::new(downcast)),
@@ -55,7 +55,7 @@ macro_rules! impl_serializable_error {
5555
};
5656
}
5757

58-
/// `SerializedError` is the wire form of errors that can be sent through the proxy.
58+
/// `SerializedError` is the wire form of errors that can be sent through network.
5959
#[derive(serde::Serialize, serde::Deserialize, Debug)]
6060
pub struct SerializedError {
6161
pub description: String,

0 commit comments

Comments
 (0)