Struct Reader

Source
pub struct Reader { /* private fields */ }
Expand description

Reader for decoding and accessing vector tile data.

Implementations§

Source§

impl Reader

Source

pub fn new(data: Vec<u8>) -> Result<Self, ParserError>

Creates a new Reader instance with the provided vector tile data.

§Arguments
  • data - The vector tile data as a byte vector.
§Returns

A result containing the Reader instance if successful, or a DecodeError if decoding the vector tile data fails.

§Examples
use mvt_reader::Reader;

let data = vec![/* Vector tile data */];
let reader = Reader::new(data);
Source

pub fn get_layer_names(&self) -> Result<Vec<String>, ParserError>

Retrieves the names of the layers in the vector tile.

§Returns

A result containing a vector of layer names if successful, or a ParserError if there is an error parsing the tile.

§Examples
use mvt_reader::Reader;

let data = vec![/* Vector tile data */];
let reader = Reader::new(data).unwrap();

match reader.get_layer_names() {
  Ok(layer_names) => {
    for name in layer_names {
      println!("Layer: {}", name);
    }
  }
  Err(error) => {
    todo!();
  }
}
Source

pub fn get_layer_metadata(&self) -> Result<Vec<Layer>, ParserError>

Retrieves metadata about the layers in the vector tile.

§Returns

A result containing a vector of Layer structs if successful, or a ParserError if there is an error parsing the tile.

§Examples
use mvt_reader::Reader;

let data = vec![/* Vector tile data */];
let reader = Reader::new(data).unwrap();

match reader.get_layer_metadata() {
  Ok(layers) => {
    for layer in layers {
      println!("Layer: {}", layer.name);
      println!("Extent: {}", layer.extent);
    }
  }
  Err(error) => {
    todo!();
  }
}
Source

pub fn get_features( &self, layer_index: usize, ) -> Result<Vec<Feature>, ParserError>

Retrieves the features of a specific layer in the vector tile.

§Arguments
  • layer_index - The index of the layer.
§Returns

A result containing a vector of features if successful, or a ParserError if there is an error parsing the tile or accessing the layer.

§Examples
use mvt_reader::Reader;

let data = vec![/* Vector tile data */];
let reader = Reader::new(data).unwrap();

match reader.get_features(0) {
  Ok(features) => {
    for feature in features {
      todo!();
    }
  }
  Err(error) => {
    todo!();
  }
}

Auto Trait Implementations§

§

impl Freeze for Reader

§

impl RefUnwindSafe for Reader

§

impl Send for Reader

§

impl Sync for Reader

§

impl Unpin for Reader

§

impl UnwindSafe for Reader

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, 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.