pub struct Reader { /* private fields */ }Expand description
Reader for decoding and accessing vector tile data.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn new(data: Vec<u8>) -> Result<Self, ParserError>
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);Sourcepub fn get_layer_names(&self) -> Result<Vec<String>, ParserError>
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!();
}
}Sourcepub fn get_features(
&self,
layer_index: usize,
) -> Result<Vec<Feature>, ParserError>
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> 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