Skip to main content

FIPSCode

Struct FIPSCode 

Source
pub struct FIPSCode(/* private fields */);
Expand description

Encodes a hierarchical FIPS geographic region code in 64 bits. Excludes the nonhierarchical codes places, congressional or state legislative districts, and ZIP code tabulation areas. (See the module level documentation.)

Implementations§

Source§

impl FIPSCode

Source

pub fn with_state(state: USState) -> Self

Constructs a new FIPSCode from a USState. Unlike the other constructors, this constructor is infallible.

Source

pub fn with_state_code(state_code: StateCode) -> Result<Self, FIPSError>

Constructs a new FIPSCode. Returns Err(()) if the data provided is out of range.

Source

pub fn with_county( state: StateCode, county: CountyCode, ) -> Result<Self, FIPSError>

Constructs a new FIPSCode. Returns Err(()) if the data provided is out of range.

Source

pub fn with_tract( state: StateCode, county: CountyCode, tract: TractCode, ) -> Result<Self, FIPSError>

Constructs a new FIPSCode. Returns Err(()) if the data provided is out of range.

Source

pub fn with_category( state: StateCode, county: CountyCode, tract: TractCode, category: SettingCategoryCode, ) -> Result<Self, FIPSError>

Constructs a new FIPSCode. Returns Err(()) if the data provided is out of range.

Source

pub fn new( state: StateCode, county: CountyCode, tract: TractCode, category: SettingCategoryCode, id: IdCode, data: DataCode, ) -> Result<Self, FIPSError>

Source

pub fn state(&self) -> Result<USState, FIPSError>

Returns the FIPS STATE as a USState enum variant. Returns Err(()) if USState cannot represent the state code. Use FIPSCode::state_code() to retrieve the state code in this case.

Source

pub fn state_code(&self) -> StateCode

Returns the FIPS STATE code as a StateCode (a u8)

Source

pub fn county_code(&self) -> CountyCode

Returns the numeric FIPS COUNTY code

Source

pub fn census_tract_code(&self) -> TractCode

Returns the numeric FIPS CENSUS TRACT code

Source

pub fn category_code(&self) -> SettingCategoryCode

Returns the numeric SETTING CATEGORY code

Source

pub fn id(&self) -> IdCode

Returns the monotonically increasing ID number as an IdCode

Source

pub fn data(&self) -> DataCode

Returns the unused data region occupying the 9 LSB

Source

pub fn set_state(&self, state: USState) -> Self

Creates a copy of self with the FIPS STATE set to state.

Source

pub fn set_state_code(&self, state_code: StateCode) -> Result<Self, FIPSError>

Creates a copy of self with the FIPS STATE set to state.

Source

pub fn set_county(&self, county: CountyCode) -> Result<Self, FIPSError>

Creates a copy of self with the FIPS COUNTY set to county.

Source

pub fn set_tract(&self, tract: TractCode) -> Result<Self, FIPSError>

Creates a copy of self with the FIPS CENSUS TRACT set to tract.

Source

pub fn set_category( &self, category: SettingCategoryCode, ) -> Result<Self, FIPSError>

Creates a copy of self with the setting category set to category.

Source

pub fn set_id(&self, id: IdCode) -> Result<Self, FIPSError>

Creates a copy of self with the ID number set to id.

Source

pub fn set_data(&self, data: DataCode) -> Result<Self, FIPSError>

Creates a copy of self with the unused data region set to data.

Source

pub fn set_data_in_place(&mut self, data: DataCode) -> Result<(), FIPSError>

Sets the unused data region occupying the 10 LSB in place. Returns Ok(()) if data is in range, Err(FIPSError) otherwise.

Source

pub fn compare_non_data(&self, other: Self) -> Ordering

Compares the given values without respect to the data region (the Least Significant Bits). Use the usual equality operators for comparing FIPSCodes including the data region.

Trait Implementations§

Source§

impl Clone for FIPSCode

Source§

fn clone(&self) -> FIPSCode

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 Copy for FIPSCode

Source§

impl Debug for FIPSCode

Source§

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

Format the code as a string of hex digits with fields separated by dashes. Note that this is different from serializing to the original FIPS code encoding. Use format_as_fips_code/format_as_fips_code for that purpose.

Source§

impl Display for FIPSCode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for FIPSCode

Source§

impl Hash for FIPSCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for FIPSCode

Source§

fn cmp(&self, other: &FIPSCode) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FIPSCode

Source§

fn eq(&self, other: &FIPSCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FIPSCode

Source§

fn partial_cmp(&self, other: &FIPSCode) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for FIPSCode

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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.