[][src]Enum geojson::GeoJson

pub enum GeoJson {
    Geometry(Geometry),
    Feature(Feature),
    FeatureCollection(FeatureCollection),
}

Variants

Geometry(Geometry)
Feature(Feature)
FeatureCollection(FeatureCollection)

Methods

impl GeoJson[src]

pub fn from_json_object(object: Map<String, JsonValue>) -> Result<Self, Error>[src]

pub fn from_json_value(value: JsonValue) -> Result<Self, Error>[src]

Converts a JSON Value into a GeoJson object.

Example

use std::convert::TryInto;
use geojson::{Feature, GeoJson, Geometry, Value};
use serde_json::json;

let json_value = json!({
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [102.0, 0.5]
    },
    "properties": null,
});

assert!(json_value.is_object());

let geojson: GeoJson = json_value.try_into().unwrap();

assert_eq!(
    geojson,
    GeoJson::Feature(Feature {
        bbox: None,
        geometry: Some(Geometry::new(Value::Point(vec![102.0, 0.5]))),
        id: None,
        properties: None,
        foreign_members: None,
    })
);

Trait Implementations

impl Clone for GeoJson[src]

impl Debug for GeoJson[src]

impl<'de> Deserialize<'de> for GeoJson[src]

impl Display for GeoJson[src]

impl<'a> From<&'a GeoJson> for Map<String, JsonValue>[src]

impl From<Feature> for GeoJson[src]

impl From<FeatureCollection> for GeoJson[src]

impl From<Geometry> for GeoJson[src]

impl FromStr for GeoJson[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<GeoJson> for GeoJson[src]

impl Serialize for GeoJson[src]

impl StructuralPartialEq for GeoJson[src]

impl TryFrom<Map<String, Value>> for GeoJson[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<Value> for GeoJson[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for GeoJson

impl Send for GeoJson

impl Sync for GeoJson

impl Unpin for GeoJson

impl UnwindSafe for GeoJson

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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.