Trait TryFromWkt

Source
pub trait TryFromWkt<T>: Sized {
    type Error;

    // Required methods
    fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>;
    fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>;
}
Expand description

Create geometries from WKT.

A default implementation exists for geo-types, or you can implement this trait for your own types.

Required Associated Types§

Required Methods§

Source

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

§Examples
// This example requires the geo-types feature (on by default).
use wkt::TryFromWkt;
use geo_types::Point;
let point: Point<f64> = Point::try_from_wkt_str("POINT(10 20)").unwrap();
assert_eq!(point.y(), 20.0);
Source

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

§Examples
// This example requires the geo-types feature (on by default).
use wkt::TryFromWkt;
use geo_types::Point;

let fake_file = "POINT(10 20)".as_bytes().to_vec();
let point: Point<f64> = Point::try_from_wkt_reader(&*fake_file).unwrap();
assert_eq!(point.y(), 20.0);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for Geometry<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for GeometryCollection<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for Line<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for LineString<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for MultiLineString<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for MultiPoint<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for MultiPolygon<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for Point<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for Polygon<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for Rect<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Source§

impl<T: CoordNum + FromStr + Default> TryFromWkt<T> for Triangle<T>

Available on crate feature geo-types only.
Source§

type Error = Error

Source§

fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>

Source§

fn try_from_wkt_reader(wkt_reader: impl Read) -> Result<Self, Self::Error>

Implementors§