### `unwrap_or` Method Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/error/type.Result.html Explains how to get the `Ok` value or a default value using `unwrap_or`. ```APIDOC ## `unwrap_or` Method ### Description Returns the contained `Ok` value or a provided default. Arguments passed to `unwrap_or` are eagerly evaluated. ### Request Example ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` ``` -------------------------------- ### `unwrap_or_else` Method Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/error/type.Result.html Details how to get the `Ok` value or compute it from a closure using `unwrap_or_else`. ```APIDOC ## `unwrap_or_else` Method ### Description Returns the contained `Ok` value or computes it from a closure. ### Request Example ```rust fn count(x: &str) -> usize { x.len() } assert_eq!(Ok(2).unwrap_or_else(count), 2); assert_eq!(Err("foo").unwrap_or_else(count), 3); ``` ``` -------------------------------- ### Get Objects and Dependencies Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.OsmPbfReader.html Retrieve all objects that satisfy a predicate, along with their dependencies. The file is decoded in parallel. Requires the underlying reader to implement the Seek trait. ```rust fn is_admin(obj: &osmpbfreader::OsmObj) -> bool { // get relations with tags[boundary] == administrative obj.is_relation() && obj.tags().contains("boundary", "administrative") } let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::Cursor::new([])); let objs = pbf.get_objs_and_deps(is_admin).unwrap(); for (id, obj) in &objs { println!("{:?}: {:?}", id, obj); } ``` -------------------------------- ### Get Objects and Dependencies Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/index.html Use this function to retrieve a subset of OSM objects along with their dependencies, such as nodes within a way. It filters objects based on a provided closure. ```rust let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::Cursor::new([])); let objs = pbf.get_objs_and_deps(|obj| { obj.is_way() && obj.tags().contains_key("highway") }) .unwrap(); for (id, obj) in &objs { println!("{:?}: {:?}", id, obj); } ``` -------------------------------- ### OsmPbfReader Initialization and Iteration Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.OsmPbfReader.html Methods for creating an OsmPbfReader and iterating over its contents. ```APIDOC ## OsmPbfReader ### Description The object to manage a pbf file. ### Methods #### `new(r: R) -> OsmPbfReader` Creates an OsmPbfReader from a Read object. #### `iter(&mut self) -> Iter<'_, R>` Returns an iterator on the OsmObj of the pbf file. ##### Example ```rust let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::empty()); for obj in pbf.iter().map(Result::unwrap) { println!("{:?}", obj); } ``` #### `par_iter(&mut self) -> ParIter<'_, R>` Returns a parallel iterator on the OsmObj of the pbf file. Several threads decode in parallel the file. The memory and CPU usage are guaranteed to be bounded even if the caller stop consuming items. ##### Example ```rust let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::empty()); for obj in pbf.par_iter().map(Result::unwrap) { println!("{:?}", obj); } ``` ``` -------------------------------- ### into_ok() - Unfailing Ok value extraction (Nightly) Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/error/type.Result.html Returns the contained Ok value without panicking. This is a nightly-only experimental API. ```APIDOC ## into_ok() ### Description Returns the contained `Ok` value, but never panics. Unlike `unwrap`, this method is known to never panic on the result types it is implemented for. Therefore, it can be used instead of `unwrap` as a maintainability safeguard that will fail to compile if the error type of the `Result` is later changed to an error that can actually occur. ### Method `into_ok()` ### Parameters None ### Request Example ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` ### Response #### Success Response (T) - The contained `Ok` value. #### Response Example ```rust // If Ok(value), returns value // This method is guaranteed not to panic. ``` ``` -------------------------------- ### DenseInfo Unknown Fields Reference Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.DenseInfo.html Gets a reference to the unknown fields of the DenseInfo message. ```rust fn unknown_fields(&self) -> &UnknownFields ``` -------------------------------- ### TryFrom and TryInto Implementations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blocks/struct.OsmObjs.html Documentation for the `TryFrom` and `TryInto` trait implementations for type conversions. ```APIDOC ### impl TryFrom for T #### Description Provides a way to attempt a conversion from type `U` into type `T`. #### Associated Types * **Error**: The type returned in the event of a conversion error. This is `Infallible` if the conversion always succeeds. #### Methods * **try_from(value: U) -> Result>::Error>** Performs the conversion from `U` to `T`. ### impl TryInto for T #### Description Provides a way to attempt a conversion from type `T` into type `U`. #### Associated Types * **Error**: The type returned in the event of a conversion error. This is the `Error` type associated with `U`'s `TryFrom` implementation. #### Methods * **try_into(self) -> Result>::Error>** Performs the conversion from `T` to `U`. ``` -------------------------------- ### Consume OsmBlobRelations to Get Owner Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobRelations.html Consumes the `OsmBlobRelations` struct and returns the owned `PrimitiveBlock`. ```rust pub fn into_owner(self) -> PrimitiveBlock ``` -------------------------------- ### DenseInfo Implementations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.DenseInfo.html This section covers the various implementations for the DenseInfo struct, including constructors, cloning, debugging, default values, and protobuf message handling. ```APIDOC ## Implementations ### impl DenseInfo #### pub fn new() -> DenseInfo Creates a new instance of DenseInfo. ### impl Clone for DenseInfo #### fn clone(&self) -> DenseInfo Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ### impl Debug for DenseInfo #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### impl<'a> Default for &'a DenseInfo #### fn default() -> &'a DenseInfo Returns the default value for a reference to DenseInfo. ### impl Default for DenseInfo #### fn default() -> DenseInfo Returns the default value for DenseInfo. ### impl Message for DenseInfo #### const NAME: &'static str = "DenseInfo" Message name as specified in `.proto` file. #### fn is_initialized(&self) -> bool True iff all required fields are initialized. Always returns `true` for protobuf 3. #### fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()> Update this message object with fields read from given stream. #### fn compute_size(&self) -> u64 Compute and cache size of this message and all nested messages. #### fn write_to_with_cached_sizes(&self, os: &mut CodedOutputStream<'_>) -> Result<()> Write message to the stream. #### fn special_fields(&self) -> &SpecialFields Special fields (unknown fields and cached size). #### fn mut_special_fields(&mut self) -> &mut SpecialFields Special fields (unknown fields and cached size). #### fn new() -> DenseInfo Create an empty message object. #### fn clear(&mut self) Reset all fields. #### fn default_instance() -> &'static DenseInfo Return a pointer to default immutable message with static lifetime. #### fn parse_from(is: &mut CodedInputStream<'_>) -> Result Parse message from stream. #### fn cached_size(&self) -> u32 Get size previously computed by `compute_size`. #### fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), Error> Write the message to the stream. #### fn write_length_delimited_to(&self, os: &mut CodedOutputStream<'_>) -> Result<()> Write the message to the stream prepending the message with message length encoded as varint. #### fn write_length_delimited_to_vec(&self, vec: &mut Vec) -> Result<()> Write the message to the vec, prepend the message with message length encoded as varint. #### fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), Error> Update this message object with fields read from given stream. #### fn parse_from_reader(reader: &mut dyn Read) -> Result Parse message from reader. Parse stops on EOF or when error encountered. #### fn parse_from_bytes(bytes: &[u8]) -> Result Parse message from byte array. #### fn check_initialized(&self) -> Result<(), Error> Check if all required fields of this object are initialized. #### fn write_to_writer(&self, w: &mut dyn Write) -> Result<(), Error> Write the message to the writer. #### fn write_to_vec(&self, v: &mut Vec) -> Result<(), Error> Write the message to bytes vec. #### fn write_to_bytes(&self) -> Result, Error> Write the message to bytes vec. #### fn write_length_delimited_to_writer(&self, w: &mut dyn Write) -> Result<()> Write the message to the writer, prepend the message with message length encoded as varint. #### fn write_length_delimited_to_bytes(&self) -> Result, Error> Write the message to the bytes vec, prepend the message with message length encoded as varint. #### fn unknown_fields(&self) -> &UnknownFields Get a reference to unknown fields. #### fn mut_unknown_fields(&mut self) -> &mut UnknownFields Get a mutable reference to unknown fields. ### impl PartialEq for DenseInfo #### fn eq(&self, other: &DenseInfo) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ``` -------------------------------- ### Create OsmPbfReader Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.OsmPbfReader.html Instantiate an OsmPbfReader from a Read object. ```rust let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::empty()); ``` -------------------------------- ### Get bottom coordinate Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.HeaderBBox.html Retrieves the bottom coordinate of the bounding box. Returns an i64 value. ```rust pub fn bottom(&self) -> i64 ``` -------------------------------- ### TryInto Trait Methods Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/struct.Relation.html Documentation for the conversion methods provided by the TryInto trait. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the fallible conversion from type T to type U. ### Parameters - **self** (T) - Required - The instance to be converted. ### Response - **Result** - Returns the converted type U on success, or the associated error type on failure. ## type Error = >::Error ### Description The associated error type returned in the event of a conversion failure. ``` -------------------------------- ### Get top coordinate Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.HeaderBBox.html Retrieves the top coordinate of the bounding box. Returns an i64 value. ```rust pub fn top(&self) -> i64 ``` -------------------------------- ### Get right coordinate Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.HeaderBBox.html Retrieves the right coordinate of the bounding box. Returns an i64 value. ```rust pub fn right(&self) -> i64 ``` -------------------------------- ### Product Implementation for Result Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/error/type.Result.html Documentation for the Product trait implementation on Result, which allows calculating the product of an iterator of Results. ```APIDOC ## fn product(iter: I) -> Result ### Description Takes each element in the Iterator: if it is an Err, no further elements are taken, and the Err is returned. Should no Err occur, the product of all elements is returned. ### Parameters #### Query Parameters - **iter** (Iterator>) - Required - The iterator of Result types to multiply. ``` -------------------------------- ### Get left coordinate Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.HeaderBBox.html Retrieves the left coordinate of the bounding box. Returns an i64 value. ```rust pub fn left(&self) -> i64 ``` -------------------------------- ### Iterate Through OSM Objects Sequentially Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/index.html The simplest way to read a PBF file is to iterate directly over `OsmObj`. Ensure proper error handling for each object. ```rust use std::process::exit; let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::empty()); for obj in pbf.iter() { // error handling: let obj = obj.unwrap_or_else(|e| {println!("{:?}", e); exit(1)}); println!("{:?}", obj); } ``` -------------------------------- ### BlobHeader::new() Constructor Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/fileformat/struct.BlobHeader.html Creates a new, empty BlobHeader instance. This is the default way to initialize a BlobHeader before populating its fields. ```rust pub fn new() -> BlobHeader ``` -------------------------------- ### ChangeSet::id() - Get ChangeSet ID Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.ChangeSet.html Retrieves the ID of the ChangeSet. Returns an i64 value. ```rust pub fn id(&self) -> i64 ``` -------------------------------- ### DenseInfo Mutate Unknown Fields Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.DenseInfo.html Gets a mutable reference to the unknown fields of the DenseInfo message. ```rust fn mut_unknown_fields(&mut self) -> &mut UnknownFields ``` -------------------------------- ### Type Conversion Utilities (TryFrom/TryInto) Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.WayIter.html Utilities for performing fallible type conversions using `TryFrom` and `TryInto` traits. ```APIDOC ### impl TryFrom #### Description Provides a way to convert a value of type `U` into a value of type `T`, returning a `Result`. #### Type Alias - **Error** (`Infallible`) - The type returned in the event of a conversion error. #### Method - **try_from**(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto #### Description Provides a way to convert a value of type `T` into a value of type `U`, returning a `Result`. #### Type Alias - **Error** (`>::Error`) - The type returned in the event of a conversion error. #### Method - **try_into**(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Iterate over PrimitiveBlock Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blocks/fn.iter.html Use this function to get an iterator over the primitive block. Requires a reference to a PrimitiveBlock. ```rust pub fn iter(block: &PrimitiveBlock) -> OsmObjs<'_> ⓘ ``` -------------------------------- ### Create a new HeaderBBox Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.HeaderBBox.html Instantiates a new HeaderBBox. This is a constructor function for creating an empty bounding box. ```rust pub fn new() -> HeaderBBox ``` -------------------------------- ### Node Implementations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.Node.html Provides details on the methods available for the Node struct, including constructors, getters, setters, and clearing functions for its fields. ```APIDOC ## Implementations ### impl Node #### `pub fn new() -> Node` Creates a new Node instance. #### `pub fn id(&self) -> i64` Returns the ID of the node. #### `pub fn clear_id(&mut self)` Clears the ID field. #### `pub fn has_id(&self) -> bool` Checks if the ID field is set. #### `pub fn set_id(&mut self, v: i64)` Sets the ID of the node. #### `pub fn lat(&self) -> i64` Returns the latitude of the node. #### `pub fn clear_lat(&mut self)` Clears the latitude field. #### `pub fn has_lat(&self) -> bool` Checks if the latitude field is set. #### `pub fn set_lat(&mut self, v: i64)` Sets the latitude of the node. #### `pub fn lon(&self) -> i64` Returns the longitude of the node. #### `pub fn clear_lon(&mut self)` Clears the longitude field. #### `pub fn has_lon(&self) -> bool` Checks if the longitude field is set. #### `pub fn set_lon(&mut self, v: i64)` Sets the longitude of the node. ``` -------------------------------- ### ChangeSet::default_instance() - Get Default Instance Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.ChangeSet.html Returns a static reference to the default immutable ChangeSet instance. ```rust fn default_instance() -> &'static ChangeSet ``` -------------------------------- ### Blob Implementations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/fileformat/struct.Blob.html Provides methods for creating, manipulating, and interacting with Blob objects. ```APIDOC ## Implementations for Blob ### `impl Blob` #### `pub fn new() -> Blob` Creates a new, empty Blob. #### `pub fn raw(&self) -> &[u8]` Returns a slice of the raw data. #### `pub fn clear_raw(&mut self)` Clears the raw data field. #### `pub fn has_raw(&self) -> bool` Checks if the raw data field is set. #### `pub fn set_raw(&mut self, v: Vec)` Sets the raw data field. #### `pub fn mut_raw(&mut self) -> &mut Vec` Returns a mutable reference to the raw data field. #### `pub fn take_raw(&mut self) -> Vec` Takes ownership of the raw data field. #### `pub fn raw_size(&self) -> i32` Returns the size of the raw data. #### `pub fn clear_raw_size(&mut self)` Clears the raw_size field. #### `pub fn has_raw_size(&self) -> bool` Checks if the raw_size field is set. #### `pub fn set_raw_size(&mut self, v: i32)` Sets the raw_size field. #### `pub fn zlib_data(&self) -> &[u8]` Returns a slice of the zlib compressed data. #### `pub fn clear_zlib_data(&mut self)` Clears the zlib_data field. #### `pub fn has_zlib_data(&self) -> bool` Checks if the zlib_data field is set. #### `pub fn set_zlib_data(&mut self, v: Vec)` Sets the zlib_data field. #### `pub fn mut_zlib_data(&mut self) -> &mut Vec` Returns a mutable reference to the zlib_data field. #### `pub fn take_zlib_data(&mut self) -> Vec` Takes ownership of the zlib_data field. #### `pub fn lzma_data(&self) -> &[u8]` Returns a slice of the lzma compressed data. #### `pub fn clear_lzma_data(&mut self)` Clears the lzma_data field. #### `pub fn has_lzma_data(&self) -> bool` Checks if the lzma_data field is set. #### `pub fn set_lzma_data(&mut self, v: Vec)` Sets the lzma_data field. #### `pub fn mut_lzma_data(&mut self) -> &mut Vec` Returns a mutable reference to the lzma_data field. #### `pub fn take_lzma_data(&mut self) -> Vec` Takes ownership of the lzma_data field. #### `pub fn OBSOLETE_bzip2_data(&self) -> &[u8]` Returns a slice of the obsolete bzip2 compressed data. #### `pub fn clear_OBSOLETE_bzip2_data(&mut self)` Clears the OBSOLETE_bzip2_data field. #### `pub fn has_OBSOLETE_bzip2_data(&self) -> bool` Checks if the OBSOLETE_bzip2_data field is set. #### `pub fn set_OBSOLETE_bzip2_data(&mut self, v: Vec)` Sets the OBSOLETE_bzip2_data field. #### `pub fn mut_OBSOLETE_bzip2_data(&mut self) -> &mut Vec` Returns a mutable reference to the OBSOLETE_bzip2_data field. #### `pub fn take_OBSOLETE_bzip2_data(&mut self) -> Vec` Takes ownership of the OBSOLETE_bzip2_data field. ### `impl Clone for Blob` #### `fn clone(&self) -> Blob` Returns a duplicate of the value. #### `fn clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. ### `impl Debug for Blob` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ### `impl<'a> Default for &'a Blob` #### `fn default() -> &'a Blob` Returns the “default value” for a type. ### `impl Default for Blob` #### `fn default() -> Blob` Returns the “default value” for a type. ### `impl Message for Blob` #### `const NAME: &'static str = "Blob"` Message name as specified in `.proto` file. #### `fn is_initialized(&self) -> bool` True iff all required fields are initialized. Always returns `true` for protobuf 3. #### `fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>` Update this message object with fields read from given stream. #### `fn compute_size(&self) -> u64` Compute and cache size of this message and all nested messages. #### `fn write_to_with_cached_sizes( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>` Write message to the stream. #### `fn special_fields(&self) -> &SpecialFields` Special fields (unknown fields and cached size). #### `fn mut_special_fields(&mut self) -> &mut SpecialFields` Special fields (unknown fields and cached size). #### `fn new() -> Blob` Create an empty message object. #### `fn clear(&mut self)` Reset all fields. #### `fn default_instance() -> &'static Blob` Return a pointer to default immutable message with static lifetime. #### `fn parse_from(is: &mut CodedInputStream<'_>) -> Result` Parse message from stream. #### `fn cached_size(&self) -> u32` Get size previously computed by `compute_size`. #### `fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), Error>` Write the message to the stream. #### `fn write_length_delimited_to( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>` Write the message to the stream prepending the message with message length encoded as varint. #### `fn write_length_delimited_to_vec(&self, vec: &mut Vec) -> Result<(), Error>` Write the message to the vec, prepend the message with message length encoded as varint. #### `fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), Error>` Update this message object with fields read from given stream. #### `fn parse_from_reader(reader: &mut dyn Read) -> Result` Parse message from reader. Parse stops on EOF or when error encountered. ``` -------------------------------- ### Get Enum Name Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/relation/enum.MemberType.html Provides the name of the enum as defined in the .proto file. Useful for introspection or debugging. ```rust const NAME: &'static str = "MemberType"; ``` -------------------------------- ### Type Conversion Utilities Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.WayParIter.html Utilities for performing type conversions using `TryFrom` and `TryInto` traits. ```APIDOC ### impl TryFrom #### Description Provides a way to convert a value of type `U` into a value of type `T`. #### Method try_from #### Endpoint N/A (Trait Implementation) #### Parameters - **value** (U) - Required - The value to convert. #### Request Body N/A #### Response - **Result** - A `Result` containing the converted value or an error. #### Error Type - **Error** (Infallible) - The type returned in the event of a conversion error. ### impl TryInto #### Description Provides a way to convert a value of type `T` into a value of type `U`. #### Method try_into #### Endpoint N/A (Trait Implementation) #### Parameters - **self** (T) - Required - The value to convert. #### Request Body N/A #### Response - **Result** - A `Result` containing the converted value or an error. #### Error Type - **Error** (>::Error) - The type returned in the event of a conversion error. ``` -------------------------------- ### Get All Enum Values Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/relation/enum.MemberType.html Returns a slice containing all defined variants of the MemberType enum. Useful for iteration or validation. ```rust const VALUES: &'static [MemberType] = &[]; ``` -------------------------------- ### Experimental and Nightly APIs Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/groups/struct.Ways.html Documentation for experimental or nightly-only iterator methods. ```APIDOC ## DELETE /api/users/{userId} ### Description Deletes a user account. ### Method DELETE ### Endpoint /api/users/{userId} ### Parameters #### Path Parameters - **userId** (string) - Required - The unique identifier of the user to delete. ### Response #### Success Response (204) - No content is returned upon successful deletion. #### Response Example (No content) ``` -------------------------------- ### Get Nth Item from OsmBlobRelations Iterator Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobRelations.html Returns the `n`th element of the iterator, consuming preceding elements. ```rust fn nth(&mut self, n: usize) -> Option ``` -------------------------------- ### Type Conversion (TryFrom/TryInto) Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.PrimitiveBlocks.html Provides implementations for `TryFrom` and `TryInto` traits for type conversions. ```APIDOC ## impl TryFrom for T ### Description Provides the `try_from` method for attempting conversions between types. ### Method N/A (Implementation of a trait) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC #### type Error = Infallible ### Description The type returned in the event of a conversion error. ### Method N/A ### Endpoint N/A ### Parameters None ### Request Example None ### Response None #### Response Example None ``` ```APIDOC #### fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Method N/A (Method on a type) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## impl TryInto for T ### Description Provides the `try_into` method for attempting conversions between types. ### Method N/A (Implementation of a trait) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC #### type Error = >::Error ### Description The type returned in the event of a conversion error. ### Method N/A ### Endpoint N/A ### Parameters None ### Request Example None ### Response None #### Response Example None ``` ```APIDOC #### fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Method N/A (Method on a type) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Last Item from OsmBlobRelations Iterator Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobRelations.html Consumes the iterator and returns the last element, or `None` if the iterator is empty. ```rust fn last(self) -> Option ``` -------------------------------- ### Get Size Hint for OsmBlobRelations Iterator Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobRelations.html Returns the lower and upper bounds of the remaining number of elements in the iterator. ```rust fn size_hint(&self) -> (usize, Option) ``` -------------------------------- ### Basic Iterator Implementations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/groups/struct.OsmObjs.html Core implementations for iterators, including `IntoIterator` and `Any`. ```APIDOC ## Basic Iterator Implementations ### `impl Any for T` ### `fn type_id(&self) -> TypeId` Gets the `TypeId` of `self`. ### `impl IntoIterator for I` ### `type Item = ::Item` The type of the elements being iterated over. ### `type IntoIter = I` Which kind of iterator are we turning this into? ### `fn into_iter(self) -> I` Creates an iterator from a value. ### `impl ParMap for I` ``` -------------------------------- ### Implement ToString for T Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/error/enum.Error.html Enables any type `T` that implements `Display` to be converted into a `String`. This is a convenient way to get a string representation. ```rust fn to_string(&self) -> String ``` -------------------------------- ### Iterator Adapters: Collection and Partitioning Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.RelationIter.html Methods for collecting iterator items into collections, partitioning them based on a predicate, and checking if an iterator is already partitioned. ```APIDOC ## Iterator Adapters: Collection and Partitioning ### Description Methods for consuming iterators to create collections, divide elements into two collections based on a predicate, and verify if elements are already partitioned. ### Methods #### `collect()` - **Description**: Transforms an iterator into a collection. - **Type Parameters**: - `B`: The type of the collection, which must implement `FromIterator`. - **Returns**: `B` #### `try_collect()` - **Description**: Fallibly transforms an iterator into a collection, short-circuiting if a failure is encountered. - **Type Parameters**: - `B`: The type of the collection, which must implement `FromIterator<::Output>`. - **Returns**: `<::Residual as Residual>::TryType` #### `collect_into(collection: &mut E)` - **Description**: Collects all the items from an iterator into a collection. - **Type Parameters**: - `E`: The type of the collection, which must implement `Extend`. - **Parameters**: - `collection` (&mut E): A mutable reference to the collection to extend. - **Returns**: `&mut E` #### `partition(f: F)` - **Description**: Consumes an iterator, creating two collections from it based on a predicate. - **Type Parameters**: - `B`: The type of the collections, which must implement `Default + Extend`. - **Parameters**: - `f` (F): A closure that takes a reference to an item and returns a boolean indicating which partition it belongs to. - **Returns**: `(B, B)` #### `is_partitioned

(predicate: P)` - **Description**: Checks if the elements of this iterator are partitioned according to the given predicate, such that all those that return `true` precede all those that return `false`. - **Parameters**: - `predicate` (P): A closure that takes an item and returns a boolean. - **Returns**: `bool` ``` -------------------------------- ### Get Enum i32 Value Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/relation/enum.MemberType.html Retrieves the integer representation of a MemberType variant. Useful for serialization or comparison with raw data. ```rust fn value(&self) -> i32 ``` -------------------------------- ### PrimitiveGroup Implementations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.PrimitiveGroup.html Provides information on the various implementations available for the PrimitiveGroup struct, including Clone, Debug, Default, and Message traits. ```APIDOC ### impl PrimitiveGroup #### pub fn new() -> PrimitiveGroup ### impl Clone for PrimitiveGroup #### fn clone(&self) -> PrimitiveGroup Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ### impl Debug for PrimitiveGroup #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### impl<'a> Default for &'a PrimitiveGroup #### fn default() -> &'a PrimitiveGroup Returns the “default value” for a type. ### impl Default for PrimitiveGroup #### fn default() -> PrimitiveGroup Returns the “default value” for a type. ### impl Message for PrimitiveGroup #### const NAME: &'static str = "PrimitiveGroup" Message name as specified in `.proto` file. #### fn is_initialized(&self) -> bool True iff all required fields are initialized. Always returns `true` for protobuf 3. #### fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()> Update this message object with fields read from given stream. #### fn compute_size(&self) -> u64 Compute and cache size of this message and all nested messages. #### fn write_to_with_cached_sizes( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()> Write message to the stream. #### fn special_fields(&self) -> &SpecialFields Special fields (unknown fields and cached size). #### fn mut_special_fields(&mut self) -> &mut SpecialFields Special fields (unknown fields and cached size). #### fn new() -> PrimitiveGroup Create an empty message object. #### fn clear(&mut self) Reset all fields. #### fn default_instance() -> &'static PrimitiveGroup Return a pointer to default immutable message with static lifetime. #### fn parse_from(is: &mut CodedInputStream<'_>) -> Result Parse message from stream. #### fn cached_size(&self) -> u32 Get size previously computed by `compute_size`. #### fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), Error> Write the message to the stream. #### fn write_length_delimited_to( &self, os: &mut CodedOutputStream<'_>, ) -> Result<(), Error> Write the message to the stream prepending the message with message length encoded as varint. #### fn write_length_delimited_to_vec(&self, vec: &mut Vec) -> Result<(), Error> Write the message to the vec, prepend the message with message length encoded as varint. #### fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), Error> Update this message object with fields read from given stream. #### fn parse_from_reader(reader: &mut dyn Read) -> Result Parse message from reader. Parse stops on EOF or when error encountered. #### fn parse_from_bytes(bytes: &[u8]) -> Result Parse message from byte array. #### fn check_initialized(&self) -> Result<(), Error> Check if all required fields of this object are initialized. #### fn write_to_writer(&self, w: &mut dyn Write) -> Result<(), Error> Write the message to the writer. #### fn write_to_vec(&self, v: &mut Vec) -> Result<(), Error> Write the message to bytes vec. #### fn write_to_bytes(&self) -> Result, Error> Write the message to bytes vec. #### fn write_length_delimited_to_writer( &self, w: &mut dyn Write, ) -> Result<(), Error> Write the message to the writer, prepend the message with message length encoded as varint. #### fn write_length_delimited_to_bytes(&self) -> Result, Error> Write the message to the bytes vec, prepend the message with message length encoded as varint. #### fn unknown_fields(&self) -> &UnknownFields Get a reference to unknown fields. #### fn mut_unknown_fields(&mut self) -> &mut UnknownFields Get a mutable reference to unknown fields. ### impl PartialEq for PrimitiveGroup #### fn eq(&self, other: &PrimitiveGroup) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ``` -------------------------------- ### Handling File Metadata Operations Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/error/type.Result.html Illustrates error handling for file system operations using `and_then`. ```APIDOC ## File Metadata Example ### Description Handles potential errors when accessing file metadata. ### Request Example ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` ``` -------------------------------- ### Get Relation Variant Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/enum.OsmObj.html Returns a reference to the Relation if the OsmObj is a Relation, otherwise returns None. Use this for type-specific access. ```rust pub fn relation(&self) -> Option<&Relation> ``` -------------------------------- ### DenseInfo New Instance Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/struct.DenseInfo.html Creates a new, empty DenseInfo message object. ```rust fn new() -> DenseInfo ``` -------------------------------- ### Get Way Variant Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/enum.OsmObj.html Returns a reference to the Way if the OsmObj is a Way, otherwise returns None. Use this for type-specific access. ```rust pub fn way(&self) -> Option<&Way> ``` -------------------------------- ### OsmBlobObjs Constructors Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobObjs.html Methods for creating new instances of OsmBlobObjs, including fallible and recoverable options. ```APIDOC ### impl OsmBlobObjs #### pub fn new( owner: PrimitiveBlock, dependent_builder: impl for<'_q> FnOnce(&'_q PrimitiveBlock) -> OsmBlockObjs<'_q>, ) -> Self Constructs a new self-referential struct. The provided `owner` will be moved into a heap allocated box. Followed by construction of the dependent value, by calling `dependent_builder` with a shared reference to the owner that remains valid for the lifetime of the constructed struct. #### pub fn try_new( owner: PrimitiveBlock, dependent_builder: impl for<'_q> FnOnce(&'_q PrimitiveBlock) -> Result, Err>, ) -> Result Constructs a new self-referential struct or returns an error. Consumes owner on error. #### pub fn try_new_or_recover( owner: PrimitiveBlock, dependent_builder: impl for<'_q> FnOnce(&'_q PrimitiveBlock) -> Result, Err>, ) -> Result Constructs a new self-referential struct or returns an error. Returns owner and error as tuple on error. ``` -------------------------------- ### Get Node Variant Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/enum.OsmObj.html Returns a reference to the Node if the OsmObj is a Node, otherwise returns None. Use this for type-specific access. ```rust pub fn node(&self) -> Option<&Node> ``` -------------------------------- ### Iterate Over All Objects Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.OsmPbfReader.html Iterate over all OsmObj in the PBF file sequentially. Ensure to handle potential errors during iteration. ```rust let mut pbf = osmpbfreader::OsmPbfReader::new(std::io::empty()); for obj in pbf.iter().map(Result::unwrap) { println!("{:?}", obj); } ``` -------------------------------- ### Get Object ID Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/enum.OsmObj.html Retrieves the unique identifier for an OsmObj. This ID is used to reference objects within the OpenStreetMap data. ```rust pub fn id(&self) -> OsmId ``` -------------------------------- ### Get Object Tags Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/enum.OsmObj.html Retrieves the tags associated with an OsmObj. Tags are key-value pairs providing additional information about the object. ```rust pub fn tags(&self) -> &Tags ``` -------------------------------- ### osmpbfreader::osmformat Module Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/osmformat/relation/index.html Documentation for the osmpbfreader::osmformat module, detailing enums and nested messages. ```APIDOC ## Module relation osmpbfreader::osmformat ### Summary Nested message and enums of message `Relation` ### Enums #### MemberType This enum represents different types of members within a Relation. ``` -------------------------------- ### Get Next Item from OsmBlobRelations Iterator Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobRelations.html Advances the iterator and returns the next `Relation` item, or `None` if the iterator is exhausted. ```rust fn next(&mut self) -> Option ``` -------------------------------- ### OsmBlobNodes Struct Methods Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/blobs/struct.OsmBlobNodes.html Methods for constructing and interacting with the OsmBlobNodes self-referential structure. ```APIDOC ## OsmBlobNodes::new ### Description Constructs a new self-referential struct. The provided `owner` is moved into a heap-allocated box, and the dependent value is constructed using the provided builder. ### Parameters - **owner** (PrimitiveBlock) - Required - The block to be owned. - **dependent_builder** (FnOnce) - Required - Closure to construct the dependent value. ## OsmBlobNodes::borrow_owner ### Description Borrows the owner PrimitiveBlock. ## OsmBlobNodes::with_dependent ### Description Calls a closure with a shared reference to the dependent value. ## OsmBlobNodes::into_owner ### Description Consumes the struct and returns the owned PrimitiveBlock. ``` -------------------------------- ### Enumerate WayIter Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/reader/struct.WayIter.html Creates an iterator that yields pairs of (index, element), starting the index from 0. The original iterator is consumed. ```rust fn enumerate(self) -> Enumerate ``` -------------------------------- ### Partial Comparison for Way Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/objects/struct.Way.html Provides a partial ordering comparison between two Way objects, returning an Option. ```rust fn partial_cmp(&self, other: &Way) -> Option ``` -------------------------------- ### DenseNodes enumerate() Method Source: https://docs.rs/osmpbfreader/0.19.1/osmpbfreader/groups/struct.DenseNodes.html Creates an iterator that yields pairs of (index, element), where index is the iteration count starting from zero. ```rust fn enumerate(self) -> Enumerate where Self: Sized, ```