Skip to main content

Serializer2D

Struct Serializer2D 

Source
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>

Source

pub fn payloads<P: AsRef<[u8]>>(self, payloads: &'a [P]) -> Self

Attach one opaque payload blob per item, in item order.

Source

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.

Source

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.

Source

pub fn interleaved(self) -> Self

Available on crate feature stream only.

Use the streaming-tuned interleaved node layout (see Index2D::to_bytes_interleaved).

Source

pub fn crs(self, crs: &'a str) -> Self

Set the coordinate reference system identifier (opaque, e.g. "EPSG:4326").

Source

pub fn content_type(self, content_type: &'a str) -> Self

Set the payload content type / media type (e.g. "application/geo+json").

Source

pub fn attribution(self, attribution: &'a str) -> Self

Set an attribution / license string.

Source

pub fn to_bytes(self) -> Result<Vec<u8>, PayloadError>

Serialize into a new buffer.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.