Skip to main content

Module redwire

Module redwire 

Source
Expand description

RedWire — RedDB’s binary TCP/TLS wire protocol.

ADR 0001 (.red/adr/0001-redwire-tcp-protocol.md) is the normative spec. This module owns the frame layout, message-kind discriminator, flags, encode/decode codec, and generic async frame I/O over byte streams. Server-side dispatch, auth policy, session loop, and listener accept stay in reddb and depend on these types.

Re-exports§

pub use builder::build_bulk_insert_binary_frame;
pub use builder::build_bulk_insert_frame;
pub use builder::build_bye_frame;
pub use builder::build_delete_frame;
pub use builder::build_dispatch_reply_frame;
pub use builder::build_error_frame;
pub use builder::build_error_frame_lossy;
pub use builder::build_get_frame;
pub use builder::build_ping_frame;
pub use builder::build_query_frame;
pub use builder::build_query_with_params_frame;
pub use builder::build_reply_frame;
pub use builder::build_request_frame;
pub use builder::rewrap_length_prefixed_handler_response;
pub use builder::BuildError;
pub use builder::FrameBuilder;
pub use bulk_binary::decode_bulk_binary_payload;
pub use bulk_binary::encode_bulk_binary_payload;
pub use bulk_binary::BulkBinaryError;
pub use bulk_binary::BulkBinaryFlavor;
pub use bulk_binary::BulkBinaryPayload;
pub use bulk_json::decode_bulk_json_payload;
pub use bulk_json::encode_bulk_json_payload;
pub use bulk_json::BulkJsonError;
pub use bulk_json::BulkJsonPayload;
pub use bulk_stream::decode_bulk_stream_rows_payload;
pub use bulk_stream::decode_bulk_stream_start_payload;
pub use bulk_stream::encode_bulk_stream_rows_payload;
pub use bulk_stream::encode_bulk_stream_start_payload;
pub use bulk_stream::BulkStreamError;
pub use bulk_stream::BulkStreamRowsPayload;
pub use bulk_stream::BulkStreamStartPayload;
pub use codec::decode_frame;
pub use codec::decode_frame_parts;
pub use codec::encode_frame;
pub use codec::frame_len_from_header;
pub use codec::FrameError;
pub use cursor::decode_close_cursor_payload;
pub use cursor::decode_declare_cursor_payload;
pub use cursor::decode_fetch_payload;
pub use cursor::encode_close_cursor_payload;
pub use cursor::encode_cursor_batch_payload;
pub use cursor::encode_cursor_ok_payload;
pub use cursor::encode_declare_cursor_payload;
pub use cursor::encode_fetch_payload;
pub use cursor::CloseCursorPayload;
pub use cursor::CursorPayloadError;
pub use cursor::DeclareCursorPayload;
pub use cursor::FetchPayload;
pub use frame::Flags;
pub use frame::Frame;
pub use frame::MessageClass;
pub use frame::MessageDirection;
pub use frame::MessageKind;
pub use frame::FRAME_HEADER_SIZE;
pub use frame::MAX_FRAME_SIZE;
pub use handshake::build_auth_fail_frame;
pub use handshake::build_auth_fail_payload;
pub use handshake::build_auth_ok_frame_from_payload;
pub use handshake::build_auth_ok_payload;
pub use handshake::build_auth_response_anonymous_payload;
pub use handshake::build_auth_response_bearer_payload;
pub use handshake::build_auth_response_frame;
pub use handshake::build_auth_response_oauth_jwt_payload;
pub use handshake::build_client_hello_frame;
pub use handshake::build_client_hello_payload;
pub use handshake::build_hello_ack;
pub use handshake::build_hello_ack_frame;
pub use handshake::build_hello_payload;
pub use handshake::choose_hello_minor_version;
pub use handshake::expect_auth_response_payload;
pub use handshake::AuthFail;
pub use handshake::AuthOk;
pub use handshake::AuthResponseKindError;
pub use handshake::Hello;
pub use handshake::HelloAck;
pub use handshake::SUPPORTED_METHODS;
pub use io::drain_next_frame;
pub use io::frame_to_bytes;
pub use io::read_frame_async;
pub use io::write_frame_async;
pub use io::RedWireIoError;
pub use operations::decode_bulk_ok_count_payload;
pub use operations::decode_bulk_ok_payload;
pub use operations::decode_delete_ok_affected;
pub use operations::decode_delete_payload;
pub use operations::decode_error_payload;
pub use operations::decode_get_payload;
pub use operations::decode_get_result_payload;
pub use operations::decode_insert_dispatch_payload;
pub use operations::decode_query_result_payload;
pub use operations::decode_text_payload;
pub use operations::encode_bulk_insert_payload;
pub use operations::encode_bulk_ok_count_payload;
pub use operations::encode_bulk_ok_payload;
pub use operations::encode_bulk_ok_payload_from_json_id_literals;
pub use operations::encode_bulk_ok_payload_from_json_ids_bytes;
pub use operations::encode_delete_ok_payload;
pub use operations::encode_get_result_payload;
pub use operations::encode_insert_payload;
pub use operations::encode_key_payload;
pub use operations::encode_query_result_summary_payload;
pub use operations::expect_bulk_ok_or_error;
pub use operations::expect_delete_ok_or_error;
pub use operations::expect_pong_reply;
pub use operations::expect_result_or_error;
pub use operations::BulkOkPayload;
pub use operations::InsertDispatchPayload;
pub use operations::KeyPayload;
pub use operations::OperationPayloadError;
pub use operations::OperationReplyError;
pub use prepared::decode_deallocate_payload;
pub use prepared::decode_execute_prepared_payload;
pub use prepared::decode_prepare_payload;
pub use prepared::encode_deallocate_payload;
pub use prepared::encode_execute_prepared_payload;
pub use prepared::encode_prepare_payload;
pub use prepared::encode_prepared_ok_payload;
pub use prepared::DeallocatePayload;
pub use prepared::ExecutePreparedPayload;
pub use prepared::PreparePayload;
pub use prepared::PreparedOkPayload;
pub use prepared::PreparedPayloadError;
pub use queue::build_event_push_payload;
pub use queue::build_event_push_payload_from_json_bytes;
pub use queue::build_queue_event_push_frame_from_json_bytes;
pub use queue::build_queue_wait_error_frame;
pub use queue::build_queue_wait_error_payload;
pub use queue::build_queue_wait_open_frame;
pub use queue::build_queue_wait_open_payload;
pub use queue::build_queue_wait_timeout_frame;
pub use queue::build_queue_wait_timeout_payload;
pub use queue::parse_queue_wait_open;
pub use queue::QueueWaitOpenRequest;
pub use queue::QueueWaitParseError;
pub use queue::WAIT_CANCELLED_CODE;
pub use queue::WAIT_EXCEEDS_CAP_CODE;
pub use queue::WAIT_FAILED_CODE;
pub use stream::build_input_stream_end_frame;
pub use stream::build_input_stream_end_payload;
pub use stream::build_input_stream_error_frame;
pub use stream::build_input_stream_error_payload;
pub use stream::build_open_ack_frame;
pub use stream::build_open_ack_payload;
pub use stream::build_open_stream_frame;
pub use stream::build_open_stream_payload;
pub use stream::build_stream_chunk_frame_from_json_bytes;
pub use stream::build_stream_chunk_payload;
pub use stream::build_stream_chunk_payload_from_json_bytes;
pub use stream::build_stream_end_frame;
pub use stream::build_stream_end_payload;
pub use stream::build_stream_error_frame;
pub use stream::build_stream_error_payload;
pub use stream::open_stream_is_input;
pub use stream::parse_input_chunk;
pub use stream::parse_input_chunk_json;
pub use stream::parse_open_input;
pub use stream::parse_open_stream;
pub use stream::parse_stream_cancel;
pub use stream::ChunkParseError;
pub use stream::InputChunk;
pub use stream::InputChunkJson;
pub use stream::OpenInputParseError;
pub use stream::OpenInputRequest;
pub use stream::OpenStreamParseError;
pub use stream::OpenStreamRequest;
pub use stream::StreamCancelRequest;
pub use ws_gate::evaluate_ws_upgrade;
pub use ws_gate::WsUpgradeRefusal;

Modules§

builder
Server-side frame construction discipline.
bulk_binary
RedWire binary bulk payload codec.
bulk_json
RedWire legacy JSON bulk-insert payload codec.
bulk_stream
RedWire legacy bulk-stream payload codec.
codec
Hand-rolled binary codec for v2 frames. No serde — the on-wire shape is fixed by ADR 0001, kept simple so a hex-dump is readable.
cursor
RedWire legacy cursor payload codec.
frame
RedWire frame layout — 16-byte header + payload, little-endian.
handshake
RedWire handshake payload contracts.
io
Async RedWire frame I/O over any Tokio byte stream.
operations
RedWire data-plane JSON payload contracts.
prepared
RedWire legacy prepared-statement payload codec.
queue
RedWire live queue-wait payload contracts.
scram
SCRAM-SHA-256 primitives and sans-I/O client/server handshake drivers.
stream
RedWire stream payload contracts.
ws_gate
Pure WebSocket upgrade-gate policy for the RedWire-over-WSS edge (issue #935, ADR 0036).

Enums§

RedWireMagicMatch
Outcome of matching an inbound peek buffer against the RedWire magic discriminator. Mirrors the service-router’s three-way detect result but stays free of router types so reddb-wire owns the classifier.
StartupError

Constants§

DEFAULT_REDWIRE_PORT
Default port for the RedWire listener.
MAX_KNOWN_MINOR_VERSION
Highest minor version the server supports. Wire-bumped as we add features that change the handshake; data-plane additions flow through Hello.features instead.
REDWIRE_MAGIC
Discriminator byte every RedWire client sends as the very first byte off the wire. The service-router detector keys off this (and so does the standalone listener path).
REDWIRE_WS_PATH
HTTP path the browser client (wss://host:port / red+wss://host:port) upgrades on to reach the RedWire-over-WebSocket edge (ADR 0036).
REDWIRE_WS_SUBPROTOCOL
WebSocket subprotocol token advertised by the RedWire-over-WSS edge (issue #935, ADR 0036). Versioned so a future framing revision can coexist with v1 clients. reddb-wire is the single source of truth — the server’s axum upgrade handler consumes this constant rather than defining its own.

Functions§

client_preface
redwire_magic_match
Classify an inbound peek buffer against the RedWire magic byte (REDWIRE_MAGIC). Pure and allocation-free so the service-router’s hot-path classifier can delegate the discriminator decision here: empty → Pending, leading 0xFE → Match, anything else → NoMatch.
supported_client_preface
validate_minor_version
validate_startup_magic