brainos-grpcadapter 0.5.0

gRPC adapter for Brain OS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Small adapter-private conversion helpers used by handlers.

/// Convert protobuf empty string to Option (proto3 defaults strings to "").
pub(crate) fn non_empty(s: String) -> Option<String> {
    if s.is_empty() {
        None
    } else {
        Some(s)
    }
}

pub(crate) fn response_to_string(content: signal::ResponseContent) -> String {
    match content {
        signal::ResponseContent::Text(t) => t,
        signal::ResponseContent::Json(v) => v.to_string(),
        signal::ResponseContent::Error(e) => e,
    }
}