Skip to main content

Crate kevy_client

Crate kevy_client 

Source
Expand description

kevy-client — unified KV facade so downstream code can switch between in-process embedded and TCP-server backends with one URL string.

use kevy_client::Connection;

// Same business code regardless of backend:
let mut conn = Connection::open(std::env::var("MY_KEVY_URL").unwrap().as_str())?;
conn.set(b"hello", b"world")?;
assert_eq!(conn.get(b"hello")?, Some(b"world".to_vec()));

URL schemes:

  • mem:// — in-process embedded, in-memory only
  • mem://<name> — shared in-process bus keyed by <name>
  • file:///abs/path / file://./rel/path — in-process embedded with persistence
  • kevy://host[:port][/db] — TCP RESP, kevy-native scheme
  • redis://host[:port][/db] — TCP RESP, standard Redis URL (alias)
  • tcp://host[:port] — TCP RESP, raw (no SELECT round-trip)

Auth (redis://user:pass@…) and TLS (rediss://) are rejected up front — kevy ships without either. v1.1.0 added the full string/hash/list/set/ zset + one-shot PUBLISH surface. v1.2.0 added the pub/sub consumer side as a separate Subscriber type — a subscribed connection cannot send normal commands, so it needs its own socket and lives outside the Connection enum. v1.3.0 routes mem://<name> / file:///path through a process-local registry so the publisher and consumer can find each other when both opens use the same URL. The trait-vs-enum design decision is enum for now (closed two-backend universe); see ROADMAP for the trait extension path.

v1.14.0 closes the wrap-parity gap against the kevy 3.17 server op surface: blocking pops (blpop/brpop/bzpopmin), hash field-TTL (hexpire/hpexpire/hpersist/httl), zset algebra (zinterstore/zunionstore/zintercard + WEIGHTS/AGGREGATE), declarative indexes (idx_*), the CDC change feed (feed_*), and non-atomic Connection::pipeline batching. The full op-family × wrap-status matrix lives in this crate’s README — anything listed there as raw-only is still reachable through Connection::pipeline / Transaction::queue argv passthrough.

Structs§

ClusterClient
One open connection per distinct shard node, with a slot → shard index so a single-key command goes straight to its owner.
FeedBatch
A batch of change frames plus the cursor to resume from.
FeedFrame
One change frame from Connection::feed_read.
IdxInfo
One declared index, as reported by IDX.LIST.
IdxPage
One page of IDX.QUERY RANGE/EQ results.
IdxRow
One IDX.QUERY hit: the row’s key plus the indexed value’s string form (the same repr the wire carries).
PipelineBuf
Client-side command buffer for Connection::pipeline. Each Self::cmd appends one RESP-encoded command; the whole buffer is flushed in a single write.
Subscriber
One subscribed connection. Owns either a TCP socket or an in-process Subscription; the variant is chosen by the URL scheme in Subscriber::open / Subscriber::connect.
SubscriberEvents
Iterator returned by Subscriber::events. Yields every pubsub frame (acks + payloads). See the method docs for termination + error semantics.
SubscriberMessages
Iterator returned by Subscriber::messages. Yields one (channel, payload) per published message / pmessage; ack frames are silently consumed and not yielded.
Transaction
One in-flight MULTI block over a Remote connection.
TransactionReplies
Typed cursor over the per-queued-command replies of a successful EXEC. Produced by Transaction::exec_typed / Transaction::exec_watched_typed. Each next_* consumes one reply; if the variant doesn’t match the extractor, an io::ErrorKind::InvalidData is returned and the cursor advances regardless (so a downstream expect_empty still works correctly).

Enums§

Connection
One open connection to a kevy backend, opaque about whether the backend is in-process or over TCP.
HExpireCond
Re-exports so downstream code can name the argument/reply types of the v1.14.0 wraps without adding kevy-embedded / kevy-resp deps. Condition flags for HEXPIRE (NX/XX/GT/LT; at most one).
IdxType
Declared scalar type for Connection::idx_create_range (TYPE i64|f64|str). Vector/ANN indexes have extra required options — declare those via Connection::idx_create_raw.
PubsubEvent
One pubsub frame received from the bus or the wire.
Reply
A parsed RESP reply (server → client) — the client-side counterpart of the crate’s encode_* functions (server-side encoders).
ZAggregate
Re-exports so downstream code can name the argument/reply types of the v1.14.0 wraps without adding kevy-embedded / kevy-resp deps. AGGREGATE mode for inter/union (Redis 6.2; default Sum).

Type Aliases§

HExpireCode
Re-exports so downstream code can name the argument/reply types of the v1.14.0 wraps without adding kevy-embedded / kevy-resp deps. Per-field reply codes for HEXPIRE-family calls (Redis 7.4): -2 key or field missing, 0 condition (NX/XX/GT/LT) not met, 1 deadline set, 2 field deleted (deadline already due).
ZPopHit
(key, member, score) from Connection::bzpopmin.