[−][src]Struct sv::messages::MessageHeader
Header that begins all messages
Fields
magic: [u8; 4]
Magic bytes indicating the network type
command: [u8; 12]
Command name
payload_size: u32
Payload size
checksum: [u8; 4]
First 4 bytes of SHA256(SHA256(payload))
Methods
impl MessageHeader
[src]
impl MessageHeader
pub const SIZE: usize
[src]
Size of the message header in bytes
pub fn size(&self) -> usize
[src]
pub fn size(&self) -> usize
Returns the size of the header in bytes
pub fn validate(&self, magic: [u8; 4], max_size: u32) -> Result<()>
[src]
pub fn validate(&self, magic: [u8; 4], max_size: u32) -> Result<()>
Checks if the header is valid
magic
- Expected magic bytes for the network
max_size
- Max size in bytes for the payload
pub fn payload(&self, reader: &mut dyn Read) -> Result<Vec<u8>>
[src]
pub fn payload(&self, reader: &mut dyn Read) -> Result<Vec<u8>>
Reads the payload and verifies its checksum
Trait Implementations
impl Serializable<MessageHeader> for MessageHeader
[src]
impl Serializable<MessageHeader> for MessageHeader
fn read(reader: &mut dyn Read) -> Result<MessageHeader>
[src]
fn read(reader: &mut dyn Read) -> Result<MessageHeader>
fn write(&self, writer: &mut dyn Write) -> Result<()>
[src]
fn write(&self, writer: &mut dyn Write) -> Result<()>
impl Clone for MessageHeader
[src]
impl Clone for MessageHeader
fn clone(&self) -> MessageHeader
[src]
fn clone(&self) -> MessageHeader
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0
[src]Performs copy-assignment from source
. Read more
impl Eq for MessageHeader
[src]
impl Eq for MessageHeader
impl Default for MessageHeader
[src]
impl Default for MessageHeader
fn default() -> MessageHeader
[src]
fn default() -> MessageHeader
impl PartialEq<MessageHeader> for MessageHeader
[src]
impl PartialEq<MessageHeader> for MessageHeader
fn eq(&self, other: &MessageHeader) -> bool
[src]
fn eq(&self, other: &MessageHeader) -> bool
fn ne(&self, other: &MessageHeader) -> bool
[src]
fn ne(&self, other: &MessageHeader) -> bool
impl Debug for MessageHeader
[src]
impl Debug for MessageHeader
impl Hash for MessageHeader
[src]
impl Hash for MessageHeader
Auto Trait Implementations
impl Send for MessageHeader
impl Send for MessageHeader
impl Sync for MessageHeader
impl Sync for MessageHeader
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self