Struct Reader

Source
pub struct Reader<T: Read + Seek> { /* private fields */ }
Expand description

Struct with the handle to the source .dbf file Responsible for reading the content

Implementations§

Source§

impl<T: Read + Seek> Reader<T>

Source

pub fn new(source: T) -> Result<Self, Error>

Creates a new reader from the source.

Reads the header and fields information as soon as its created.

Creating a reader from a file path using the from_path is the prefered way of doing it as it wraps the file in a BufReader for performance.

§Example
let mut reader = typed_shapefile::Reader::from_path("tests/data/line.dbf")?;
let records = reader.read()?;
use std::fs::File;
let f = File::open("tests/data/line.dbf").unwrap();
let reader = typed_shapefile::Reader::new(f)?;
Source

pub fn new_with_encoding<E: Encoding + 'static>( source: T, encoding: E, ) -> Result<Self, Error>

Creates a new reader from the source and reads strings using the encoding provided.

See Self::new for more information.

Source

pub fn set_encoding<E: Encoding + 'static>(&mut self, encoding: E)

Source

pub fn header(&self) -> &Header

Returns the header of the file

Source

pub fn fields(&self) -> &[FieldInfo]

Returns the fields contained in the opened file

Source

pub fn iter_records_as<R: ReadableRecord>(&mut self) -> RecordIterator<'_, T, R>

Creates an iterator of records of the type you want

Source

pub fn iter_record_rows(&mut self) -> RecordRowIterator<'_, T>

Shortcut function to get an iterator over the Records in the file

Source

pub fn iter_records(&mut self) -> RecordIterator<'_, T, Record>

Shortcut function to get an iterator over the Records in the file

Source

pub fn read_as<R: ReadableRecord>(&mut self) -> Result<Vec<R>, Error>

Reads all the records of the file inside a Vec

Source

pub fn read(&mut self) -> Result<Vec<Record>, Error>

Make the Reader read the Records

§Examples
use std::fs::File;
let mut reader = typed_shapefile::Reader::from_path("tests/data/line.dbf")?;
let records = reader.read()?;
assert_eq!(records.len(), 1);
Source

pub fn seek(&mut self, index: usize) -> Result<(), Error>

Seek to the start of the record at index

Source

pub fn into_table_info(self) -> TableInfo

Consumes the reader, and returns the info that allow to create a writer that would write a file with the same structure.

let mut reader = typed_shapefile::Reader::from_path("some_file.dbf")?;
let records = reader.read()?;
let table_info = reader.into_table_info();
let writer_1 = typed_shapefile::TableWriterBuilder::from_table_info(table_info.clone())
        .build_with_file_dest("new_file_1.dbf");

let writer_2 = typed_shapefile::TableWriterBuilder::from_table_info(table_info)
        .build_with_file_dest("new_file_2.dbf");
Source§

impl Reader<BufReader<File>>

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Creates a new dbase Reader from a path

§Example
let reader = typed_shapefile::Reader::from_path("tests/data/line.dbf")?;
Source

pub fn from_path_with_encoding<P: AsRef<Path>, E: Encoding + 'static>( path: P, encoding: E, ) -> Result<Self, Error>

Creates a new dbase Reader from a path and reads string using the encoding provided.

Trait Implementations§

Source§

impl<T: Clone + Read + Seek> Clone for Reader<T>

Source§

fn clone(&self) -> Reader<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Reader<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Reader<T>

§

impl<T> !Send for Reader<T>

§

impl<T> !Sync for Reader<T>

§

impl<T> Unpin for Reader<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Reader<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V