Struct shapefile::writer::Writer[][src]

pub struct Writer<T: Write + Seek> { /* fields omitted */ }

The Writer writes a complete shapefile that is, it writes the 3 mandatory files (.shp, .shx, .dbf)

The recommended way to create a new shapefile is via the Writer::from_path or Writer::from_path_with_info associated functions.

Examples

To create a Writer that writes a .dbf file that has the same structure as .dbf read earlier you will have to do:

let mut reader = shapefile::Reader::from_path("tests/data/multipatch.shp")?;
let shape_records = reader.read()?;
let table_info = reader.into_table_info();

let writer = shapefile::Writer::from_path_with_info("new_multipatch.shp", table_info);

Implementations

impl<T: Write + Seek> Writer<T>[src]

pub fn new(shape_writer: ShapeWriter<T>, dbase_writer: TableWriter<T>) -> Self[src]

Creates a new writer using the provided ShapeWriter and TableWriter

Example

Creating a Writer that writes to in memory buffers.

use std::convert::TryInto;
let mut shp_dest = std::io::Cursor::new(Vec::<u8>::new());
let mut shx_dest = std::io::Cursor::new(Vec::<u8>::new());
let mut dbf_dest = std::io::Cursor::new(Vec::<u8>::new());

let shape_writer = shapefile::ShapeWriter::with_shx(&mut shp_dest, &mut shx_dest);
let dbase_writer = dbase::TableWriterBuilder::new()
    .add_character_field("Name".try_into().unwrap(), 50)
    .build_with_dest(&mut dbf_dest);

let shape_writer = shapefile::Writer::new(shape_writer, dbase_writer);

pub fn write_shape_and_record<S: EsriShape, R: WritableRecord>(
    &mut self,
    shape: &S,
    record: &R
) -> Result<(), Error>
[src]

pub fn write_shapes_and_records<'a, S: EsriShape + 'a, R: WritableRecord + 'a, C: IntoIterator<Item = (&'a S, &'a R)>>(
    self,
    container: C
) -> Result<(), Error>
[src]

impl Writer<BufWriter<File>>[src]

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

Creates all the files needed for the shapefile to be complete (.shp, .shx, .dbf)

use std::convert::TryInto;
let table_builder = dbase::TableWriterBuilder::new()
    .add_character_field("name".try_into().unwrap(), 50);
let writer = shapefile::Writer::from_path("new_cities.shp", table_builder)?;

pub fn from_path_with_info<P: AsRef<Path>>(
    path: P,
    table_info: TableInfo
) -> Result<Self, Error>
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Writer<T> where
    T: RefUnwindSafe

impl<T> Send for Writer<T> where
    T: Send

impl<T> Sync for Writer<T> where
    T: Sync

impl<T> Unpin for Writer<T> where
    T: Unpin

impl<T> UnwindSafe for Writer<T> where
    T: 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<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.