pub struct SpaceTrackQuery { /* private fields */ }Expand description
Builder for constructing SpaceTrack API queries.
Uses a fluent API where each method returns Self to allow method chaining.
Call build() to produce the URL path string.
§Examples
use brahe::spacetrack::{SpaceTrackQuery, RequestClass, SortOrder, OutputFormat};
// Query latest GP data for ISS
let query = SpaceTrackQuery::new(RequestClass::GP)
.filter("NORAD_CAT_ID", "25544")
.order_by("EPOCH", SortOrder::Desc)
.limit(1);
let url_path = query.build();
assert!(url_path.contains("/class/gp/"));
assert!(url_path.contains("/NORAD_CAT_ID/25544/"));
// Query with custom format
let query = SpaceTrackQuery::new(RequestClass::GP)
.filter("NORAD_CAT_ID", "25544")
.format(OutputFormat::TLE);
let url_path = query.build();
assert!(url_path.contains("/format/tle"));Implementations§
Source§impl SpaceTrackQuery
impl SpaceTrackQuery
Sourcepub fn new(class: RequestClass) -> Self
pub fn new(class: RequestClass) -> Self
Sourcepub fn controller(self, controller: RequestController) -> Self
pub fn controller(self, controller: RequestController) -> Self
Override the default controller for this query.
Most users will not need to call this method, as each request class has an appropriate default controller.
§Arguments
controller- The controller to use
Sourcepub fn filter(self, field: &str, value: &str) -> Self
pub fn filter(self, field: &str, value: &str) -> Self
Add a filter predicate to the query.
Filters restrict the results to records where the specified field matches
the given value. Use operator functions from the operators module to
construct comparison values (e.g., operators::greater_than("25544")).
§Arguments
field- The field name (e.g., “NORAD_CAT_ID”, “EPOCH”)value- The filter value, optionally with operator prefix
§Examples
use brahe::spacetrack::{SpaceTrackQuery, RequestClass, operators};
let query = SpaceTrackQuery::new(RequestClass::GP)
.filter("NORAD_CAT_ID", "25544")
.filter("EPOCH", &operators::greater_than("2024-01-01"));Sourcepub fn order_by(self, field: &str, order: SortOrder) -> Self
pub fn order_by(self, field: &str, order: SortOrder) -> Self
Add an ordering clause to the query.
Multiple order_by calls are cumulative - records are sorted by the first field, then by subsequent fields for ties.
§Arguments
field- The field to sort byorder- The sort direction (ascending or descending)
§Examples
use brahe::spacetrack::{SpaceTrackQuery, RequestClass, SortOrder};
let query = SpaceTrackQuery::new(RequestClass::GP)
.order_by("EPOCH", SortOrder::Desc);Sourcepub fn limit_offset(self, count: u32, offset: u32) -> Self
pub fn limit_offset(self, count: u32, offset: u32) -> Self
Set the maximum number of results and an offset.
§Arguments
count- Maximum number of recordsoffset- Number of records to skip
Sourcepub fn format(self, format: OutputFormat) -> Self
pub fn format(self, format: OutputFormat) -> Self
Set the output format for query results.
If not specified, defaults to JSON.
§Arguments
format- The desired output format
Sourcepub fn predicates_filter(self, fields: &[&str]) -> Self
pub fn predicates_filter(self, fields: &[&str]) -> Self
Specify which fields to include in the response.
This is a predicates filter that limits which fields are returned for each record. Useful for reducing response size.
§Arguments
fields- Slice of field names to include
Sourcepub fn metadata(self, enabled: bool) -> Self
pub fn metadata(self, enabled: bool) -> Self
Enable or disable metadata in the response.
When enabled, the response includes query metadata (e.g., total count).
§Arguments
enabled- Whether to include metadata
Sourcepub fn distinct(self, enabled: bool) -> Self
pub fn distinct(self, enabled: bool) -> Self
Enable or disable distinct results.
When enabled, duplicate records are removed from the results.
§Arguments
enabled- Whether to return distinct results
Sourcepub fn empty_result(self, enabled: bool) -> Self
pub fn empty_result(self, enabled: bool) -> Self
Enable or disable empty result return.
When enabled, an empty query (no results) returns an empty array/set instead of an error response.
§Arguments
enabled- Whether to allow empty results
Sourcepub fn build(&self) -> String
pub fn build(&self) -> String
Build the URL path string for this query.
Produces the path portion of the Space-Track API URL, which should be appended to the base URL and authentication endpoint.
§Returns
String- The URL path string for this query
§Examples
use brahe::spacetrack::{SpaceTrackQuery, RequestClass, SortOrder};
let query = SpaceTrackQuery::new(RequestClass::GP)
.filter("NORAD_CAT_ID", "25544")
.order_by("EPOCH", SortOrder::Desc)
.limit(1);
let path = query.build();
assert_eq!(
path,
"/basicspacedata/query/class/gp/NORAD_CAT_ID/25544/orderby/EPOCH%20desc/limit/1/format/json"
);Sourcepub fn output_format(&self) -> OutputFormat
pub fn output_format(&self) -> OutputFormat
Returns the output format for this query.
Returns OutputFormat::JSON if no format has been explicitly set.
Sourcepub fn request_class(&self) -> RequestClass
pub fn request_class(&self) -> RequestClass
Returns the request class for this query.
Trait Implementations§
Source§impl Clone for SpaceTrackQuery
impl Clone for SpaceTrackQuery
Source§fn clone(&self) -> SpaceTrackQuery
fn clone(&self) -> SpaceTrackQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpaceTrackQuery
impl RefUnwindSafe for SpaceTrackQuery
impl Send for SpaceTrackQuery
impl Sync for SpaceTrackQuery
impl Unpin for SpaceTrackQuery
impl UnsafeUnpin for SpaceTrackQuery
impl UnwindSafe for SpaceTrackQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.