Struct pgwire::codec::Cursor [−][src]
Expand description
Decodes data within pgwire messages.
The API provided is very similar to bytes::Buf
, but operations return
errors rather than panicking. This is important for safety, as we don’t want
to crash if the user sends us malformatted pgwire messages.
There are also some special-purpose methods, like Cursor::read_cstr
,
that are specific to pgwire messages.
Fields
buf: &'a [u8]
Implementations
Constructs a new Cursor
from a byte slice. The cursor will begin
decoding from the beginning of the slice.
Returns the next byte, advancing the cursor by one byte.
Returns the next null-terminated string. The null character is not included the returned string. The cursor is advanced past the null- terminated string.
If there is no null byte remaining in the string, returns
CodecError::StringNoTerminator
. If the string is not valid UTF-8,
returns an io::Error
with an error kind of
io::ErrorKind::InvalidInput
.
NOTE(benesch): it is possible that returning a string here is wrong, and we should be returning bytes, so that we can support messages that are not UTF-8 encoded. At the moment, we’ve not discovered a need for this, though, and using proper strings is convenient.
Reads the next 16-bit signed integer, advancing the cursor by two bytes.
Reads the next 32-bit signed integer, advancing the cursor by four bytes.
Reads the next 32-bit unsigned integer, advancing the cursor by four bytes.
Reads the next 16-bit format code, advancing the cursor by two bytes.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more