Struct cassandra_protocol::frame::Envelope
source · pub struct Envelope {
pub version: Version,
pub direction: Direction,
pub flags: Flags,
pub opcode: Opcode,
pub stream_id: StreamId,
pub body: Vec<u8>,
pub tracing_id: Option<Uuid>,
pub warnings: Vec<String>,
}
Fields§
§version: Version
§direction: Direction
§flags: Flags
§opcode: Opcode
§stream_id: StreamId
§body: Vec<u8>
§tracing_id: Option<Uuid>
§warnings: Vec<String>
Implementations§
source§impl Envelope
impl Envelope
sourcepub fn new_req_auth_response(token_bytes: CBytes, version: Version) -> Envelope
pub fn new_req_auth_response(token_bytes: CBytes, version: Version) -> Envelope
Creates new envelope of type AuthResponse
.
source§impl Envelope
impl Envelope
pub fn new_req_batch( query: BodyReqBatch, flags: Flags, version: Version ) -> Envelope
source§impl Envelope
impl Envelope
pub fn new_req_execute( id: &CBytesShort, result_metadata_id: Option<&CBytesShort>, query_parameters: &QueryParams, flags: Flags, version: Version ) -> Envelope
source§impl Envelope
impl Envelope
sourcepub fn new_req_options(version: Version) -> Envelope
pub fn new_req_options(version: Version) -> Envelope
Creates new envelope of type options
.
source§impl Envelope
impl Envelope
pub fn new_req_query( query: String, consistency: Consistency, values: Option<QueryValues>, with_names: bool, page_size: Option<CInt>, paging_state: Option<CBytes>, serial_consistency: Option<Consistency>, timestamp: Option<CLong>, keyspace: Option<String>, now_in_seconds: Option<CInt>, flags: Flags, version: Version ) -> Envelope
pub fn new_query( query: BodyReqQuery, flags: Flags, version: Version ) -> Envelope
source§impl Envelope
impl Envelope
sourcepub fn new_req_register(
events: Vec<SimpleServerEvent>,
version: Version
) -> Envelope
pub fn new_req_register( events: Vec<SimpleServerEvent>, version: Version ) -> Envelope
Creates new envelope of type REGISTER
.
source§impl Envelope
impl Envelope
pub fn new( version: Version, direction: Direction, flags: Flags, opcode: Opcode, stream_id: StreamId, body: Vec<u8>, tracing_id: Option<Uuid>, warnings: Vec<String> ) -> Self
pub fn request_body(&self) -> Result<RequestBody>
pub fn response_body(&self) -> Result<ResponseBody>
pub fn tracing_id(&self) -> &Option<Uuid>
pub fn warnings(&self) -> &[String]
sourcepub fn from_buffer(
data: &[u8],
compression: Compression
) -> Result<ParsedEnvelope, ParseEnvelopeError>
pub fn from_buffer( data: &[u8], compression: Compression ) -> Result<ParsedEnvelope, ParseEnvelopeError>
Parses the raw bytes of a cassandra envelope returning a ParsedEnvelope
struct.
The typical use case is reading from a buffer that may contain 0 or more envelopes and where
the last envelope may be incomplete. The possible return values are:
Ok(ParsedEnvelope)
- The first envelope in the buffer has been successfully parsed.Err(ParseEnvelopeError::NotEnoughBytes)
- There are not enough bytes to parse a single envelope,Envelope::from_buffer
should be recalled when it is possible that there are more bytes.Err(_)
- The envelope is malformed and you should close the connection as this method does not provide a way to tell how many bytes to advance the buffer in this case.