Struct celestia_types::Share
source · pub struct Share {
pub data: [u8; 512],
}Expand description
A single fixed-size chunk of data which is used to form an ExtendedDataSquare.
All data in Celestia is split into Shares before being put into a
block’s data square. See Blob::to_shares.
All shares have the fixed size of 512 bytes and the following structure:
| Namespace | InfoByte | (optional) sequence length | data |
sequence length is the length of the original data in bytes and is present only in the first of the shares the data was split into.
Fields§
§data: [u8; 512]A raw data of the share.
Implementations§
sourcepub fn from_raw(data: &[u8]) -> Result<Self>
pub fn from_raw(data: &[u8]) -> Result<Self>
Create a new Share from raw bytes.
§Errors
This function will return an error if the slice length isn’t
SHARE_SIZE or if a namespace encoded in the share is invalid.
§Example
use celestia_types::Share;
let raw = [0; 512];
let share = Share::from_raw(&raw).unwrap();sourcepub fn sequence_length(&self) -> Option<u32>
pub fn sequence_length(&self) -> Option<u32>
For first share in a sequence, return sequence length, None for continuation shares
Trait Implementations§
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)