pub struct Serializer2D<'a> { /* private fields */ }Expand description
Builder for Index2D serialization, created by Index2D::serialize.
Set optional per-item payloads, the streaming-tuned interleaved layout, and
descriptive metadata (CRS / content type / attribution), then call
to_bytes or to_bytes_into. The
metadata strings are stored opaquely and read back with
read_metadata.
Implementations§
Source§impl<'a> Serializer2D<'a>
impl<'a> Serializer2D<'a>
Sourcepub fn payloads<P: AsRef<[u8]>>(self, payloads: &'a [P]) -> Self
pub fn payloads<P: AsRef<[u8]>>(self, payloads: &'a [P]) -> Self
Attach one opaque payload blob per item, in item order.
Sourcepub fn records(self, stride: usize, flat: &'a [u8]) -> Self
pub fn records(self, stride: usize, flat: &'a [u8]) -> Self
Attach a fixed-width payload: flat is the concatenation of one
stride-byte record per item, in item order (item i is
flat[i * stride ..][.. stride]). Because every record is the same size,
the offset table is dropped (the reader addresses record r by
arithmetic), which shrinks the file and lets a view borrow the records as
a zero-copy typed slice. flat.len() must be num_items * stride.
Sourcepub fn triangles<T: Triangle2>(self, triangles: &'a [T]) -> Self
pub fn triangles<T: Triangle2>(self, triangles: &'a [T]) -> Self
Attach a fixed-width triangle payload (T =
Triangle2D for f64 or
Triangle2DF32 for f32): one triangle per item,
in item order. A convenience over records; pair it with
Index2D::from_triangles.
Sourcepub fn interleaved(self) -> Self
Available on crate feature stream only.
pub fn interleaved(self) -> Self
stream only.Use the streaming-tuned interleaved node layout (see
Index2D::to_bytes_interleaved).
Sourcepub fn crs(self, crs: &'a str) -> Self
pub fn crs(self, crs: &'a str) -> Self
Set the coordinate reference system identifier (opaque, e.g. "EPSG:4326").
Sourcepub fn content_type(self, content_type: &'a str) -> Self
pub fn content_type(self, content_type: &'a str) -> Self
Set the payload content type / media type (e.g. "application/geo+json").
Sourcepub fn attribution(self, attribution: &'a str) -> Self
pub fn attribution(self, attribution: &'a str) -> Self
Set an attribution / license string.
Sourcepub fn to_bytes_into(self, out: &mut Vec<u8>) -> Result<(), PayloadError>
pub fn to_bytes_into(self, out: &mut Vec<u8>) -> Result<(), PayloadError>
Serialize into a reused buffer (cleared first).
Auto Trait Implementations§
impl<'a> Freeze for Serializer2D<'a>
impl<'a> RefUnwindSafe for Serializer2D<'a>
impl<'a> Send for Serializer2D<'a>
impl<'a> Sync for Serializer2D<'a>
impl<'a> Unpin for Serializer2D<'a>
impl<'a> UnsafeUnpin for Serializer2D<'a>
impl<'a> UnwindSafe for Serializer2D<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more