Skip to content

Commit

Permalink
fix(stac)!: make io::read_json pub(crate)
Browse files Browse the repository at this point in the history
It doesn't really belong in our lib's API.
  • Loading branch information
gadomski committed Aug 26, 2024
1 parent ab2e8ec commit df01015
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
9 changes: 1 addition & 8 deletions stac/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ pub fn read<T: Href + DeserializeOwned>(href: impl ToString) -> Result<T> {
Ok(value)
}

/// Reads any deserializable value from the JSON at an href.
///
/// # Examples
///
/// ```
/// let value: stac::Item = stac::read_json("data/simple-item.json").unwrap();
/// ```
pub fn read_json<T>(href: &str) -> Result<T>
pub(crate) fn read_json<T>(href: &str) -> Result<T>
where
T: DeserializeOwned,
{
Expand Down
2 changes: 1 addition & 1 deletion stac/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ mod tests {

#[test]
fn deserialize_invalid_type_field() {
let mut item: Value = crate::read_json("data/simple-item.json").unwrap();
let mut item: Value = crate::io::read_json("data/simple-item.json").unwrap();
item["type"] = "Item".into(); // must be "Feature"
assert!(serde_json::from_value::<Item>(item).is_err());
}
Expand Down
2 changes: 1 addition & 1 deletion stac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub use {
extensions::{Extension, Extensions},
fields::Fields,
href::{href_to_url, Href},
io::{read, read_json},
io::read,
item::{FlatItem, Item, Properties, ITEM_TYPE},
item_collection::{ItemCollection, ITEM_COLLECTION_TYPE},
link::{Link, Links},
Expand Down
2 changes: 1 addition & 1 deletion stac/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod tests {
assert_eq!(asset.bands[2].name.as_ref().unwrap(), "b");
assert_eq!(asset.bands[3].name.as_ref().unwrap(), "nir");

let expected: Value = crate::read_json("examples/bands-v1.1.0-beta.1.json").unwrap();
let expected: Value = crate::io::read_json("examples/bands-v1.1.0-beta.1.json").unwrap();
assert_json_eq!(expected, serde_json::to_value(item).unwrap());

let collection = Collection::new("an-id", "a description");
Expand Down

0 comments on commit df01015

Please sign in to comment.