pub trait ResultBody:
Send
+ Sync
+ Debug {
// Required methods
fn to_json(&self) -> Value;
fn as_any(&self) -> &dyn Any;
// Provided methods
fn element_count(&self) -> u64 { ... }
fn byte_count(&self) -> Option<u64> { ... }
fn to_text(&self) -> String { ... }
}Expand description
Trait for adapter-specific result bodies.
The adapter defines its own concrete result type and implements
this trait. Internal adapter code can downcast via as_any() to
access native types (e.g., CQL rows, HTTP response structs).
External consumers call to_json() for a universal representation.
The element_count() and byte_count() methods support result
traversal — the framework uses these to verify that result data
was fully received and to record consumption metrics.
Required Methods§
Provided Methods§
Sourcefn element_count(&self) -> u64
fn element_count(&self) -> u64
Count of logical elements in this result (rows, records, items). Used by the result traverser for metrics. Default 1 (one result).
Sourcefn byte_count(&self) -> Option<u64>
fn byte_count(&self) -> Option<u64>
Size in bytes of the result payload, if known. Used by the result traverser for throughput metrics.
Sourcefn to_text(&self) -> String
fn to_text(&self) -> String
SRD-66 §“Surface 1” body projection — return the body’s
canonical text representation for use by result-binding
expressions (the magic body: Str extern). Default
implementation falls back to serde_json::to_string
over to_json(); adapters with native text bodies (e.g.
TextBody, the CQL describe row) override to return
the underlying text directly.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".