pub trait Query: Send + 'static {
// Required methods
fn to_bytes(&self) -> Result<Vec<u8>, CodecError>;
fn from_bytes(bytes: &[u8]) -> Result<Self, CodecError>
where Self: Sized;
}Expand description
A read-only query served by the StateMachine.
Queries never enter the log; they are answered locally after the ReadIndex
protocol confirms the leader is current (read-consistency). They still cross task
boundaries and may be sent to a remote leader, hence Send + 'static +
serde. Unlike a Command, a query need not be Clone.
Required Methods§
Sourcefn to_bytes(&self) -> Result<Vec<u8>, CodecError>
fn to_bytes(&self) -> Result<Vec<u8>, CodecError>
Encode this query to postcard bytes for the wire.
§Errors
Returns CodecError if serialization fails.
Sourcefn from_bytes(bytes: &[u8]) -> Result<Self, CodecError>where
Self: Sized,
fn from_bytes(bytes: &[u8]) -> Result<Self, CodecError>where
Self: Sized,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".