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> Base32Len for T
impl<T> Base32Len for T
source§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
Calculate the base32 serialized length
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> CheckBase32<Vec<u5>> for T
impl<T> CheckBase32<Vec<u5>> for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
source§impl<T> ToBase32 for T
impl<T> ToBase32 for T
source§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
Encode as base32 and write it to the supplied writer
Implementations shouldn’t allocate.
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)