[][src]Struct osmpbf::blob::BlobReader

pub struct BlobReader<R: Read + Send> { /* fields omitted */ }

A reader for PBF files that allows iterating over Blobs.

Implementations

impl<R: Read + Send> BlobReader<R>[src]

pub fn new(reader: R) -> BlobReader<R>

Notable traits for BlobReader<R>

impl<R: Read + Send> Iterator for BlobReader<R> type Item = Result<Blob>;
[src]

Creates a new BlobReader.

Example

use osmpbf::*;

let f = std::fs::File::open("tests/test.osm.pbf")?;
let buf_reader = std::io::BufReader::new(f);

let reader = BlobReader::new(buf_reader);

impl BlobReader<BufReader<File>>[src]

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>[src]

Tries to open the file at the given path and constructs a BlobReader from this.

Errors

Returns the same errors that std::fs::File::open returns.

Example

use osmpbf::*;

let reader = BlobReader::from_path("tests/test.osm.pbf")?;

impl<R: Read + Seek + Send> BlobReader<R>[src]

pub fn new_seekable(mut reader: R) -> Result<BlobReader<R>>[src]

Creates a new BlobReader from the given reader that is seekable and will be initialized with a valid offset.

Example

use osmpbf::*;

let f = std::fs::File::open("tests/test.osm.pbf")?;
let buf_reader = std::io::BufReader::new(f);

let mut reader = BlobReader::new_seekable(buf_reader)?;
let first_blob = reader.next().unwrap()?;

assert_eq!(first_blob.offset(), Some(ByteOffset(0)));

pub fn seek(&mut self, pos: ByteOffset) -> Result<()>[src]

Seek to an offset in bytes from the start of the stream.

Example

use osmpbf::*;

let mut reader = BlobReader::from_path("tests/test.osm.pbf")?;
let first_blob = reader.next().unwrap()?;
let second_blob = reader.next().unwrap()?;

reader.seek(first_blob.offset().unwrap())?;

let first_blob_again = reader.next().unwrap()?;
assert_eq!(first_blob.offset(), first_blob_again.offset());

pub fn seek_raw(&mut self, pos: SeekFrom) -> Result<u64>[src]

Seek to an offset in bytes. (See std::io::Seek)

pub fn next_header_skip_blob(
    &mut self
) -> Option<Result<(BlobHeader, Option<ByteOffset>)>>
[src]

Read and return next BlobHeader but skip the following Blob. This allows really fast iteration of the PBF structure if only the byte offset and BlobType are important. On success, returns the BlobHeader and the byte offset of the header which can also be used as an offset for reading the entire Blob (including header).

impl BlobReader<BufReader<File>>[src]

pub fn seekable_from_path<P: AsRef<Path>>(
    path: P
) -> Result<BlobReader<BufReader<File>>>
[src]

Creates a new BlobReader from the given path that is seekable and will be initialized with a valid offset.

Example

use osmpbf::*;

let mut reader = BlobReader::seekable_from_path("tests/test.osm.pbf")?;
let first_blob = reader.next().unwrap()?;

assert_eq!(first_blob.offset(), Some(ByteOffset(0)));

Trait Implementations

impl<R: Clone + Read + Send> Clone for BlobReader<R>[src]

impl<R: Debug + Read + Send> Debug for BlobReader<R>[src]

impl<R: Read + Send> Iterator for BlobReader<R>[src]

type Item = Result<Blob>

The type of the elements being iterated over.

Auto Trait Implementations

impl<R> RefUnwindSafe for BlobReader<R> where
    R: RefUnwindSafe
[src]

impl<R> Send for BlobReader<R>[src]

impl<R> Sync for BlobReader<R> where
    R: Sync
[src]

impl<R> Unpin for BlobReader<R> where
    R: Unpin
[src]

impl<R> UnwindSafe for BlobReader<R> where
    R: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.