Struct ZoomSet

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

ZoomSet is a set of zoom levels represented as a 32-bit unsigned integer where each bit represents a zoom level (0 <= z <= 30). BY DEFAULT: The least significant bit represents zoom level 0 and the SECOND most significant bit represents zoom level 30. BUT if the MOST significant bit is 1, then the order is reversed.

§Examples

use utiles_core::zoom::ZoomSet;
let zset_int_fwd = ZoomSet::new(0b0000_0000_0000_0000_0000_0000_0000_0111);
//                            ^ is 1 so the order is forward/default
let zset_int_rev = ZoomSet::new(0b1111_0000_0000_0000_0000_0000_0000_0000);
//                            ^ is 1 so the order is reversed
let zooms_fwd_vec: Vec<u8> = zset_int_fwd.into();
assert_eq!(zooms_fwd_vec, vec![0, 1, 2]);
let zooms_rev_vec: Vec<u8> = zset_int_rev.into();
assert_eq!(zooms_rev_vec, vec![0, 1, 2]);

Implementations§

Source§

impl ZoomSet

ZoomSet implementation

Source

pub fn new(zset: u32) -> Self

Create a new ZoomSet from a u32

Source

pub fn from_zooms(zooms: &[u8]) -> Self

Create a new ZoomSet from a vector of zoom levels

Source

pub fn to_zooms(&self) -> Vec<u8>

Return a vector of zoom levels from a zoom-set u32

Source

pub fn all() -> Self

Source

pub fn zoom_ranges(&self) -> Vec<ZoomRange>

Trait Implementations§

Source§

impl BitAnd<ZoomSet> for u32

Source§

type Output = ZoomSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: ZoomSet) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd<u32> for ZoomSet

Source§

type Output = ZoomSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: u32) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd<u8> for ZoomSet

Source§

type Output = ZoomSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: u8) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd for ZoomSet

Source§

type Output = ZoomSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl Clone for ZoomSet

Source§

fn clone(&self) -> ZoomSet

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 ZoomSet

Source§

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

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

impl Default for ZoomSet

Source§

fn default() -> ZoomSet

Returns the “default value” for a type. Read more
Source§

impl From<ZoomRange> for ZoomSet

Convert range of zoom levels to a set of zoom levels

§Examples

use utiles_core::zoom::{ZoomRange, ZoomSet};
let zrange = ZoomRange::new(0, 7);
let zset: ZoomSet = zrange.into();
assert_eq!(zset, ZoomSet::new(0b0000_0000_0000_0000_0000_0000_1111_1111));
Source§

fn from(zoom_range: ZoomRange) -> Self

Converts to this type from the input type.
Source§

impl From<ZoomSet> for Vec<u8>

Source§

fn from(zset: ZoomSet) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for ZoomSet

Source§

fn from(zset: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for ZoomSet

Source§

fn from(zoom: u8) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ZoomSet

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Serialize for ZoomSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<Vec<u8>> for ZoomSet

Source§

type Error = UtilesCoreError

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

fn try_from(zvec: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for ZoomSet

Source§

impl Eq for ZoomSet

Source§

impl StructuralPartialEq for ZoomSet

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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, 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.