glide_shared.ffi_helpers
Shared FFI helper utilities for converting Python arguments to C-compatible arrays.
FFIClientTypeEnum
Client type enum matching the Rust ClientType repr.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
264 265 266 267 268 | |
encode_arg(arg)
Encode a single argument to bytes.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
138 139 140 141 142 143 144 | |
to_c_strings(ffi, args)
Convert Python arguments to C-compatible (pointers_array, lengths_array, buffers).
The returned buffers list must be kept alive for the duration of the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
147 148 149 150 151 152 153 154 155 156 157 | |
to_c_route_ptr_and_len(ffi, route)
Convert a Route to C-compatible (route_ptr, route_len, route_bytes).
The returned route_bytes must be kept alive for the duration of the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
to_c_route_info(ffi, route)
Convert a Route to a C RouteInfo* for batch operations.
Returns (route_info_ptr, refs) where refs must be kept alive for the duration of the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
parse_push_notification(ffi, kind, message_ptr, message_len, channel_ptr, channel_len, pattern_ptr, pattern_len)
Parse raw FFI push notification data into (message_kind, message_bytes, channel_bytes, pattern_bytes).
Returns (kind_str, message, channel, pattern) where pattern may be None.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
convert_commands_to_c_batch_info(ffi, commands, is_atomic)
Convert a list of (request_type, args) tuples to a C BatchInfo*.
Returns (batch_info, refs) where refs must be kept alive during the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
create_c_batch_options(ffi, route, retry_server_error=False, retry_connection_error=False, timeout=None)
Create a C BatchOptionsInfo* from Python parameters.
Returns (batch_options, refs) where refs must be kept alive during the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
create_address_resolver_callback(ffi, resolver_fn)
Create an AddressResolverCallback for the FFI from a Python resolver function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
The CFFI instance. |
required | |
resolver_fn
|
A callable(host: str, port: int) -> (resolved_host: str, resolved_port: int). |
required |
Returns:
| Type | Description |
|---|---|
|
The CFFI callback object. Caller must keep a reference to prevent GC. |
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
create_credential_provider_callback(ffi, credential_provider_fn, *, callback_id=None, event_loop=None, trio_token=None, allow_async=False, provider_owner=None)
Register a credential owner behind an FFI-stable weak trampoline.
The callback follows the native stateless tri-state protocol: 0 means failure, 1 means success, and 2 requests larger buffers. A provider can be called twice during large-value negotiation; no result is cached between those calls.
Returns:
| Type | Description |
|---|---|
|
A |
|
|
is None when no provider is configured. Otherwise the caller strongly |
|
|
owns the owner and must close it at the lifecycle transition where new |
|
|
callbacks are no longer allowed. The module registry holds it weakly. |
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | |
handle_command_result(ffi, lib, command_result, response_handler)
Handle a synchronous CommandResult* from FFI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
The CFFI instance. |
required | |
lib
|
The FFI library. |
required | |
command_result
|
The CommandResult* pointer from FFI. |
required | |
response_handler
|
A callable that takes a response pointer and returns the parsed result. |
required |
Returns:
| Type | Description |
|---|---|
|
The parsed response value. |
Raises:
| Type | Description |
|---|---|
ClosingError
|
If result is NULL. |
RequestError subclass
|
If the result contains an error. |
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | |
parse_inline_pubsub(payload)
Parse inline pubsub payload from pipe.
Format: kind(4) msg_len(4) msg(...) ch_len(4) ch(...) pat_len(4) pat(...)
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | |