Trait rubble::bytes::FromBytes [−][src]
pub trait FromBytes<'a>: Sized {
fn from_bytes(bytes: &mut ByteReader<'a>) -> Result<Self, Error>;
}
Expand description
Trait for decoding values from a byte slice.
Required methods
fn from_bytes(bytes: &mut ByteReader<'a>) -> Result<Self, Error>
fn from_bytes(bytes: &mut ByteReader<'a>) -> Result<Self, Error>
Decode a Self
from a byte slice, advancing bytes
to point past the data that was read.
If bytes
contains data not valid for the target type, or contains an insufficient number
of bytes, an error will be returned and the state of bytes
is unspecified (it can point to
arbitrary data).
Implementations on Foreign Types
Implementors
Decodes an advertising channel PDU (consisting of header and payload) from raw bytes.
Decodes ServiceUuids
from a byte sequence containing:
TYPE
: The right “(In)complete List of N-bit Service Class UUIDs” type. Both the complete and incomplete type are accepted.UUID
…: n*2/4/16 Bytes of UUID data, in little endian.
Creates a BytesOr
that stores bytes that can be decoded to a sequence of T
s.
This will check that bytes
can indeed be decoded as a sequence of T
s, and returns an error
if not. Note that this will read as many T
s as possible until the ByteReader
is at its
end of input. Any trailing data after the list of T
s will result in an error.
The ByteReader
will be advanced to point past the decoded list of T
s if the conversion
succeeds. In that case, it will be at EOF and no more data can be read.
Creates a BytesOr
that stores bytes that can be decoded to a T
.
This will check that bytes
can indeed be decoded as a T
using its FromBytes
implementation, and returns an error if not.
The ByteReader
will be advanced to point past the decoded T
if the conversion succeeds.