Skip to content

Commit

Permalink
Unified anyhow result return types
Browse files Browse the repository at this point in the history
  • Loading branch information
pwalski committed Jun 28, 2023
1 parent a0a8af7 commit 937ed20
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions core/gsb-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ impl GsbApiService {
pub(crate) type GsbError = ya_service_bus::Error;

#[derive(Message, Serialize, Deserialize, Debug)]
#[rtype(result = "Result<(), anyhow::Error>")]
#[rtype(result = "anyhow::Result<()>")]
struct WsRequest {
id: String,
component: String,
payload: Vec<u8>,
}

#[derive(Message, Debug)]
#[rtype(result = "Result<(), anyhow::Error>")]
#[rtype(result = "anyhow::Result<()>")]
pub(crate) struct WsResponse {
pub id: String,
pub response: WsResponseMsg,
Expand Down Expand Up @@ -373,10 +373,7 @@ mod flexbuffer_util {
}
}

pub(crate) fn read_string(
reader: &MapReader<&[u8]>,
key: &str,
) -> Result<String, anyhow::Error> {
pub(crate) fn read_string(reader: &MapReader<&[u8]>, key: &str) -> anyhow::Result<String> {
match reader.index(key) {
Ok(field) => match field.get_str() {
Ok(txt) => Ok(txt.to_string()),
Expand All @@ -389,7 +386,7 @@ mod flexbuffer_util {
pub(crate) fn as_map<'a>(
reader: &Reader<&'a [u8]>,
allow_empty: bool,
) -> Result<MapReader<&'a [u8]>, anyhow::Error> {
) -> anyhow::Result<MapReader<&'a [u8]>> {
match reader.get_map() {
Ok(map) => {
if allow_empty || !map.is_empty() {
Expand Down

0 comments on commit 937ed20

Please sign in to comment.