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

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

A reader for PBF files that allows iterating over Blobs.

Methods

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

Important traits for BlobReader<R>
pub fn new(reader: R) -> BlobReader<R>[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> BlobReader<R>[src]

pub fn new_seekable(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)

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> Clone for BlobReader<R>[src]

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

impl<R: Read> 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

impl<R> Send for BlobReader<R> where
    R: Send

impl<R> Sync for BlobReader<R> where
    R: Sync

impl<R> Unpin for BlobReader<R> where
    R: Unpin

impl<R> UnwindSafe for BlobReader<R> where
    R: UnwindSafe

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> ParallelBridge for T where
    T: Send + Iterator,
    <T as Iterator>::Item: Send
[src]

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.