pub struct CancelKey(/* private fields */);Expand description
Opaque cancellation secret carried by BackendKeyData and
CancelRequest.
PostgreSQL 18 accepts 1 through 256 bytes when decoding a cancel request.
A backend key has the stricter 4 through 256 byte range in protocol 3.2,
and is exactly 4 bytes before protocol 3.2.
Implementations§
Source§impl CancelKey
impl CancelKey
pub fn new(bytes: impl Into<Vec<u8>>) -> Result<Self, PgWireError>
pub fn from_i32(secret_key: i32) -> Self
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Sourcepub fn with_middleware_prefix(&self, prefix: &[u8]) -> Result<Self, PgWireError>
pub fn with_middleware_prefix(&self, prefix: &[u8]) -> Result<Self, PgWireError>
Prefix middleware-owned routing data while retaining the complete downstream cancellation secret.
PostgreSQL does not prescribe a framing format for middleware data.
Each layer therefore owns the prefix length it adds and passes that
same length to Self::remove_middleware_prefix on the return path.
Sourcepub fn remove_middleware_prefix(
&self,
prefix_length: usize,
) -> Result<(Vec<u8>, Self), PgWireError>
pub fn remove_middleware_prefix( &self, prefix_length: usize, ) -> Result<(Vec<u8>, Self), PgWireError>
Remove one middleware prefix and return both the layer data and the downstream cancellation secret.
pub fn validate_for_backend_key_data( &self, version: ProtocolVersion, ) -> Result<(), PgWireError>
Trait Implementations§
impl Eq for CancelKey
impl StructuralPartialEq for CancelKey
Auto Trait Implementations§
impl Freeze for CancelKey
impl RefUnwindSafe for CancelKey
impl Send for CancelKey
impl Sync for CancelKey
impl Unpin for CancelKey
impl UnsafeUnpin for CancelKey
impl UnwindSafe for CancelKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more