Add serde derive features to spatial-coordinate-systems

This commit is contained in:
Austen Adler 2023-03-28 23:34:05 -04:00
parent f687c45b6d
commit 8dece0b547
4 changed files with 12 additions and 3 deletions

1
Cargo.lock generated
View File

@ -1372,6 +1372,7 @@ version = "0.1.0"
dependencies = [
"nom",
"pluscodes",
"serde",
"thiserror",
"url",
"utm",

View File

@ -7,6 +7,7 @@ edition = "2021"
[features]
wasm_bindgen = ["dep:wasm-bindgen"]
serde = ["dep:serde"]
[dependencies]
# Excluding because rustc-serialize does not work with wasm
@ -28,3 +29,4 @@ thiserror = "1.0.38"
url = "2.3.1"
wasm-bindgen={version="0.2",optional=true}
serde={version="1",optional=true,features=["derive"]}

View File

@ -1,6 +1,8 @@
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::fmt;
#[cfg(feature = "wasm_bindgen")]
use wasm_bindgen::prelude::*;
use std::fmt;
use nom::{
character::complete::space0,
@ -15,6 +17,7 @@ use crate::{
};
#[cfg_attr(feature = "wasm_bindgen", wasm_bindgen(getter_with_clone))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq, Debug, Clone, Copy)]
pub struct LatLon {
lat: f64,

View File

@ -1,5 +1,3 @@
#[cfg(feature = "wasm_bindgen")]
use wasm_bindgen::prelude::*;
use crate::{common::parse_f64, Error, LatLon};
use nom::{
branch::alt,
@ -10,13 +8,18 @@ use nom::{
sequence::tuple,
IResult,
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use url::Url;
#[cfg(feature = "wasm_bindgen")]
use wasm_bindgen::prelude::*;
// TODO: Set a reasonable OSM zoom level
const OPENSTREETMAP_ZOOM_LEVEL: u8 = 19;
#[cfg_attr(feature = "wasm_bindgen", wasm_bindgen(getter_with_clone))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq, Debug, Clone)]
pub struct CoordinateUrls {
// TODO: These should be getters only