Build a macro to simplify the Rust code, handling:
unpack proto and pack proto.let req = GetMonthRequest::decode(&v[..]).expect("Failed to decode");
error handling
The current function signatures are eth_service_v1_blockmeta_getmonth(v: Vec<u8>) -> Result<Vec<u8>, String>
We should return Result<MyCustomObject, substreams_sink_kv::error:Error>
Where the substreams_sink_kv::error:Error object should contain a message and potentially a GRPC Status code that we can return to the user
Ideally this
#[wasmedge_bindgen]
pub fn eth_service_v1_blockmeta_getmonth(v: Vec<u8>) -> Result<Vec<u8>, String> {
let req = GetMonthRequest::decode(&v[..]).expect("Failed to decode");
.....
let out = MonthResponse{}
Ok(out.encode_to_vec())
}
becomes
#[wasmedge_bindgen]
#[my_macro]
pub fn eth_service_v1_blockmeta_getmonth(req: GetMonthRequest) -> Result<MonthResponse, substreams_sink_kv::error:Error> {
let req = GetMonthRequest::decode(&v[..]).expect("Failed to decode");
.....
let out = MonthResponse{}
Ok(out)
}
knowing that Result<Vec<u8>, String> needs to be the final output we would wrap the user's custom proto object and user define error into a intermidate proto object to handle these cases in the go handler
Build a macro to simplify the Rust code, handling:
unpack proto and pack proto.
let req = GetMonthRequest::decode(&v[..]).expect("Failed to decode");
error handling
The current function signatures are
eth_service_v1_blockmeta_getmonth(v: Vec<u8>) -> Result<Vec<u8>, String>
We should return
Result<MyCustomObject, substreams_sink_kv::error:Error>
Where the
substreams_sink_kv::error:Error
object should contain a message and potentially aGRPC Status code
that we can return to the userIdeally this
becomes
knowing that
Result<Vec<u8>, String>
needs to be the final output we would wrap the user's customproto
object and user define error into a intermidateproto
object to handle these cases in the go handler