MCPcopy Create free account
hub / github.com/deventlab/d-engine / extract_read_payload

Function extract_read_payload

d-engine-server/src/api/embedded_client.rs:101–115  ·  view source on GitHub ↗

Unwrap a `ClientResponsePayload` as a `ReadResults`, returning a `Protocol { InvalidResponse }` error for any other variant. Centralises the match so both `get_with_consistency` and `get_multi_with_consistency` share identical error semantics, and so the logic can be unit-tested without standing up a full Raft channel.

(result: Option<ClientResponsePayload>)

Source from the content-addressed store, hash-verified

99/// `get_multi_with_consistency` share identical error semantics, and so
100/// the logic can be unit-tested without standing up a full Raft channel.
101fn extract_read_payload(result: Option<ClientResponsePayload>) -> ClientApiResult<ReadResults> {
102 match result {
103 Some(ClientResponsePayload::Read(r)) => Ok(r),
104 Some(ClientResponsePayload::Write(_)) => Err(ClientApiError::Protocol {
105 code: ErrorCode::InvalidResponse,
106 message: "expected ReadData payload, got WriteResult".to_string(),
107 supported_versions: None,
108 }),
109 None => Err(ClientApiError::Protocol {
110 code: ErrorCode::InvalidResponse,
111 message: "expected ReadData payload, got None".to_string(),
112 supported_versions: None,
113 }),
114 }
115}
116
117/// Zero-overhead KV client for embedded mode.
118///

Calls

no outgoing calls