MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / from_string

Method from_string

fendermint/rpc/src/client.rs:345–372  ·  view source on GitHub ↗
(response: impl AsRef<[u8]>)

Source from the content-addressed store, hash-verified

343 R: trpc::Response,
344 {
345 fn from_string(response: impl AsRef<[u8]>) -> Result<Self, trpc::Error> {
346 let wrapper: Result<trpc::response::Wrapper<Self>, trpc::Error> =
347 serde_json::from_slice(response.as_ref()).map_err(trpc::Error::serde);
348
349 let response_body = || String::from_utf8_lossy(response.as_ref()).to_string();
350
351 match wrapper {
352 Err(e) => {
353 tracing::error!(
354 error = e.to_string(),
355 response = response_body(),
356 "failed to parse JSON-RPC response"
357 );
358 Err(e)
359 }
360 Ok(wrapper) => match wrapper.into_result() {
361 Err(e) => {
362 tracing::error!(
363 error = e.to_string(),
364 response = response_body(),
365 "error from JSON-RPC"
366 );
367 Err(e)
368 }
369 Ok(response) => Ok(response),
370 },
371 }
372 }
373
374 fn from_reader(reader: impl std::io::prelude::Read) -> Result<Self, trpc::Error> {
375 let wrapper: trpc::response::Wrapper<Self> =

Callers

nothing calls this directly

Calls 2

to_stringMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected