Skip to main content

AcsGeoidQuery

Enum AcsGeoidQuery 

Source
pub enum AcsGeoidQuery {
    State(Option<State>),
    County(Option<State>, Option<County>),
    CountySubdivision(State, Option<County>, Option<CountySubdivision>),
    Place(Option<State>, Option<Place>),
    CensusTract(State, Option<County>, Option<CensusTract>),
    BlockGroup(State, Option<County>, Option<CensusTract>, Option<BlockGroup>),
}
Expand description

enumeration representing the scopes of various ACS queries.

when running an ACS query at a given GEOID hierarchical level, there are a set of required (aka, not Optional) components which can be coupled with Optional (wildcard) components to construct a query.

Variants§

Implementations§

Source§

impl AcsGeoidQuery

Source

pub fn new( geoid: Option<Geoid>, wildcard: Option<GeoidType>, ) -> Result<AcsGeoidQuery, String>

§Examples

when no wildcard is provided, the query is constructed for an exact location, which should return a single result.

use bamcensus_core::model::identifier::{fips, Geoid, GeoidType};
use bamcensus_acs::model::AcsGeoidQuery;;

let geoid = Geoid::County(fips::State(8), fips::County(1));
let query = AcsGeoidQuery::new(Some(geoid), None).unwrap();
let key = query.to_query_key();
assert_eq!(key, String::from("&for=county:001&in=state:08"));

some combinations simply append a wildcard one level below the geoid, for example, tacking a county=* on top of state=08.

use bamcensus_core::model::identifier::{fips, Geoid, GeoidType};
use bamcensus_acs::model::AcsGeoidQuery;;

let geoid = Geoid::State(fips::State(8));
let wildcard = GeoidType::County;
let query = AcsGeoidQuery::new(Some(geoid), Some(wildcard)).unwrap();
let key = query.to_query_key();
assert_eq!(key, String::from("&for=county:*&in=state:08"));

some interpolate the wildcard into a geoid in ways that do not require being reported in the query, such as adding a wildcard to a tract query. in this case, the query simply drops the county wildcard, as it is implied.

use bamcensus_core::model::identifier::{fips, Geoid, GeoidType};
use bamcensus_acs::model::AcsGeoidQuery;;

let geoid = Geoid::CensusTract(fips::State(8), fips::County(1), fips::CensusTract(1));
let wildcard = GeoidType::County;
let query = AcsGeoidQuery::new(Some(geoid), Some(wildcard)).unwrap();
let key = query.to_query_key();
assert_eq!(key, String::from("&for=tract:000001&in=state:08"));
§Returns

URL query string for calls to the US Census ACS API “for” section, which set the spatial scope and granularity of the query result.

Source

pub fn to_query_key(&self) -> String

a query key for a unique data row in the census API. depending on the AcsGeoidQuery and the presence/absence of FIPS values, wildcards (“*”) will be inserted at any level.

Source

pub fn response_geoid_type(&self) -> GeoidType

Source

pub fn response_column_names(&self) -> Vec<String>

Source

pub fn response_column_count(&self) -> usize

Source

pub fn get_geoid_type(&self) -> GeoidType

Source

pub fn build_deserialize_geoid_fn(&self) -> DeserializeGeoidFn

builds a function that unpacks the ACS query values representing a geoid. these return as values in an array of different lengths, depending on the scope of the original query.

Trait Implementations§

Source§

impl Clone for AcsGeoidQuery

Source§

fn clone(&self) -> AcsGeoidQuery

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AcsGeoidQuery

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more