Module builder

Source
Expand description

Builder for constructing RESP2/3 frames

Generic wrapper mainly used as helper for creating RESP frames. However, it can also be used to execute custom/arbitrary commands. See CustomCommand for more details.

§Creating generic frames

The following example demonstrates the creation of command frame for HGET.

use embedded_redis::commands::builder::CommandBuilder;
use redis_protocol::resp2::types::BytesFrame as Resp2Frame;

let _frame: Resp2Frame = CommandBuilder::new("HGET")
    .arg_static("field1")
    .arg_static("foo")
    .into();

§Improved performance

For best performance, especially with large amounts of data, it is recommended to use Bytes.

use embedded_redis::commands::builder::CommandBuilder;
// Using Bytes avoids data copy, as clone() is shallow
let value = Bytes::from_static("Large value".as_bytes());

let _frame: Resp2Frame = CommandBuilder::new("HSET")
    .arg_static("myhash")
    .arg_static("field1")
    .arg(&value)
    .into();

Structs§

CommandBuilder
Builder for constructing RESP2/3 frames

Traits§

IsNullFrame
Unification for null check of RESP2/3 frames
ToBytesMap
Trait for converting RESP2 arrays or RESP3 maps
ToInteger
Unification for extracting integer value of Frames
ToStringBytes
Trait for string extraction of RESP2/3 frames
ToStringOption
Unification for to_string() of RESP2/3 frames