pub struct SGData(/* private fields */);Expand description
Scattered, gathered, immutable, arc-ed data
Allows zero-copy processing of streamed data, read into fixed-size buffers. Especially useful for high-performance, parallel data processing.
A piece of data potentially scattered between multiple parts, which themselves might be slices of shared-ownership underlying data.
SGData is essentially semantic wrapper over Vec<ArcRef<Vec<u8>, [u8]>>
For illustration:
frames: [ Buf ][ Buf ][ Buf ][ Buf ]
edges: | | | | |
| | | | |
\ /\ / \ / \ /\ /\ / \ /
\ / || || | | \ / \ / \ /
sgdata parts: C1[0] C1[1] C2[0] C3[0] C3[1] C3[2] C4[0]Arbitrary-sized data is being read into frames and edges between
logical parts are being found. Then sgdata objects are created,
aggregating parts of frames while holding reference-counted shared
ownership over frames.
Implementations§
Source§impl SGData
impl SGData
pub fn empty() -> Self
pub fn from_single(v: Vec<u8>) -> Self
pub fn from_vec(v: Vec<ArcRef<Vec<u8>, [u8]>>) -> Self
pub fn from_many(v: Vec<Vec<u8>>) -> Self
pub fn is_empty(&self) -> bool
pub fn as_parts(&self) -> &[ArcRef<Vec<u8>, [u8]>] ⓘ
pub fn as_vec(&self) -> &Vec<ArcRef<Vec<u8>, [u8]>> ⓘ
pub fn as_vec_mut(&mut self) -> &mut Vec<ArcRef<Vec<u8>, [u8]>> ⓘ
pub fn push_vec(&mut self, v: Vec<u8>)
pub fn push_arcref(&mut self, arcref: ArcRef<Vec<u8>, [u8]>)
Sourcepub fn to_linear(&self) -> ArcRef<Vec<u8>, [u8]>
pub fn to_linear(&self) -> ArcRef<Vec<u8>, [u8]>
Convert to linear (single vector) form
If self is empty or already contains only one piece,
this is cheap.
If self is scattered between many pices, this requires
copying all the data into a new, big chunk.