[][src]Struct usgs_eros_client::Client

pub struct Client { /* fields omitted */ }

USGS EROS M2M API client. This is the main interaction point with the API. The instantiation needs valid user credentials that are used to initiate a session and get an API token. The token is automatically freed when the Client goes out of scope.

Each Client method then corresponds to an API call and generates a corresponding RequestBuilder object that can be used to build up a request. In order to have the correct builder methods available, the trait corresponding to the particular request type must be imported. The request can then be called and awaited on.

Implementations

impl Client[src]

pub async fn new<'_>(credentials: &'_ Credentials) -> Result<Client>[src]

Instantiate a client session with the given credentials

Example

use usgs_eros_client::types::Credentials;

   let credentials = Credentials::from_env()?;
   let client = Client::new(&credentials).await?;

pub fn dataset(&self) -> RequestBuilder<'_, DatasetRequest>[src]

Retrieve a dataset by its id or name

Example

use usgs_eros_client::endpoints::DatasetRequestBuilder;

   let dataset = client
       .dataset()
       .name("lsr_landsat_8_c1")
       .call()
       .await?;

pub fn dataset_coverage(
    &self,
    dataset_name: &str
) -> RequestBuilder<'_, DatasetCoverageRequest>
[src]

Retrieve dataset coverage by name

Example

use usgs_eros_client::endpoints::DatasetCoverageRequestBuilder;

   let dataset_coverage = client
       .dataset_coverage("lsr_landsat_8_c1")
       .call()
       .await?;

Search available datasets

Example

use usgs_eros_client::endpoints::DatasetSearchBuilder;
use usgs_eros_client::types::{Coordinate, DateRange, SpatialFilter};

   let lower_left = Coordinate::new(-10.5, 10.5).unwrap();
   let upper_right = Coordinate::new(-10.5, 10.5).unwrap();
   let date_range = DateRange::new("2014-05-01", "2014-05-30").unwrap();

   let search_result = client
       .dataset_search()
       .dataset_name("lsr_landsat")
       .temporal_filter(date_range)
       .spatial_filter(SpatialFilter::mbr(lower_left, upper_right))
       .call()
       .await?;

Search for scenes

Example

use std::path::Path;
use usgs_eros_client::endpoints::SceneSearchBuilder;
use usgs_eros_client::types::{TemporalFilter, CloudCoverFilter, GeoJson, SpatialFilter, MetadataFilter, SortDirection, MetadataType};

   let acquisition_filter = TemporalFilter::new("2018-11-30", "2018-12-30").unwrap();
   let cloud_filter = CloudCoverFilter::new(0, 100, true);
   let geojson = GeoJson::from_file(Path::new("test-data/geojson-filter.json")).unwrap();
   let spatial_filter = SpatialFilter::geojson(geojson);
   let meta1 = MetadataFilter::between("5e7c418226384db5", 10, 50);
   let meta2 = MetadataFilter::between("5e7c4182b7148b69", 50, 90);
   let meta_filter = MetadataFilter::and(vec![meta1, meta2]);
   let search_result = client
       .scene_search("lsr_landsat_8_c1")
       .max_results(20)
       .starting_number(1)
       .sort_direction(SortDirection::ASC)
       .metadata_type(MetadataType::Summary)
       .acquisition_filter(acquisition_filter)
       .cloud_cover_filter(cloud_filter)
       .spatial_filter(spatial_filter)
       .metadata_filter(meta_filter)
       .call()
       .await?;

pub async fn close_session(__arg0: Self) -> Result<ApiResponse>[src]

Explicitly close the given session by logging out and releasing the token

Example


let credentials = Credentials::from_env()?;
let client = Client::new(&credentials).await?;
client.close_session().await?;
// The client has been consumed here

Trait Implementations

impl Clone for Client[src]

impl Debug for Client[src]

impl Drop for Client[src]

fn drop(&mut self)[src]

Release the token automatically when Client goes out of scope.

Auto Trait Implementations

impl !RefUnwindSafe for Client

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

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> From<T> for T[src]

impl<T> Instrument 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, 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.