Skip to main content

SpaceTrackQuery

Struct SpaceTrackQuery 

Source
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

Source

pub fn new(class: RequestClass) -> Self

Create a new query builder for the specified request class.

Uses the default controller for the request class.

§Arguments
  • class - The request class to query
§Examples
use brahe::spacetrack::{SpaceTrackQuery, RequestClass};

let query = SpaceTrackQuery::new(RequestClass::GP);
Source

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
Source

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"));
Source

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 by
  • order - The sort direction (ascending or descending)
§Examples
use brahe::spacetrack::{SpaceTrackQuery, RequestClass, SortOrder};

let query = SpaceTrackQuery::new(RequestClass::GP)
    .order_by("EPOCH", SortOrder::Desc);
Source

pub fn limit(self, count: u32) -> Self

Set the maximum number of results to return.

§Arguments
  • count - Maximum number of records
Source

pub fn limit_offset(self, count: u32, offset: u32) -> Self

Set the maximum number of results and an offset.

§Arguments
  • count - Maximum number of records
  • offset - Number of records to skip
Source

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
Source

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
Source

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
Source

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
Source

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
Source

pub fn favorites(self, favorites: &str) -> Self

Set a favorites filter for the query.

§Arguments
  • favorites - The favorites identifier
Source

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"
);
Source

pub fn output_format(&self) -> OutputFormat

Returns the output format for this query.

Returns OutputFormat::JSON if no format has been explicitly set.

Source

pub fn request_class(&self) -> RequestClass

Returns the request class for this query.

Trait Implementations§

Source§

impl Clone for SpaceTrackQuery

Source§

fn clone(&self) -> SpaceTrackQuery

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpaceTrackQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T