wkt/from_wkt.rs
1/// Create geometries from WKT.
2///
3/// A default implementation exists for [geo-types](../geo-types), or you can implement this trait
4/// for your own types.
5pub trait TryFromWkt<T>: Sized {
6 type Error;
7
8 /// # Examples
9 #[cfg_attr(feature = "geo-types", doc = "```")]
10 #[cfg_attr(not(feature = "geo-types"), doc = "```ignore")]
11 /// // This example requires the geo-types feature (on by default).
12 /// use wkt::TryFromWkt;
13 /// use geo_types::Point;
14 /// let point: Point<f64> = Point::try_from_wkt_str("POINT(10 20)").unwrap();
15 /// assert_eq!(point.y(), 20.0);
16 /// ```
17 fn try_from_wkt_str(wkt_str: &str) -> Result<Self, Self::Error>;
18
19 /// # Examples
20 #[cfg_attr(feature = "geo-types", doc = "```")]
21 #[cfg_attr(not(feature = "geo-types"), doc = "```ignore")]
22 /// // This example requires the geo-types feature (on by default).
23 /// use wkt::TryFromWkt;
24 /// use geo_types::Point;
25 ///
26 /// let fake_file = "POINT(10 20)".as_bytes().to_vec();
27 /// let point: Point<f64> = Point::try_from_wkt_reader(&*fake_file).unwrap();
28 /// assert_eq!(point.y(), 20.0);
29 /// ```
30 fn try_from_wkt_reader(wkt_reader: impl std::io::Read) -> Result<Self, Self::Error>;
31}