Skip to main content

TickGeneration

Struct TickGeneration 

Source
pub struct TickGeneration { /* private fields */ }
Expand description

One validated selection for generated numeric tick positions.

Targets allow nice-step deviation; maxima bound the complete in-domain list, including endpoint positions. Preferred intervals are tried before bounded coarser sources. Exact caller ticks take precedence over every selection.

use lichtung_plot::TickGeneration;
let linear = TickGeneration::additive(0.25)?;
let logarithmic = TickGeneration::log10_decades(2)?;
assert_eq!(linear.additive_step(), Some(0.25));
assert_eq!(logarithmic.decade_step(), Some(2));
assert_eq!(TickGeneration::target(5)?.target_count(), Some(5));
assert_eq!(TickGeneration::maximum(6)?.get_maximum_count(), Some(6));
assert!(TickGeneration::default().is_automatic());
assert!(TickGeneration::target(0).is_err());
assert!(TickGeneration::maximum(10_001).is_ok());

The choice and payload are private:

ⓘ
let _ = lichtung_plot::TickGeneration::Target(0);

Requests are owned and cloneable, not Copy:

ⓘ
use lichtung_plot::TickGeneration;
let request = TickGeneration::automatic();
let moved = request;
let _ = (moved, request);

Implementations§

Source§

impl TickGeneration

Source

pub fn function<F>(function: F) -> TickGeneration
where F: for<'a> Fn(&TickContext<'a>) -> Result<TickPositions, Error> + Send + Sync + 'static,

Generate positions from the final domain and actual assigned span. Clones share the immutable callback; exact ticks suppress it entirely.

Source

pub const fn automatic() -> TickGeneration

Use renderer-owned automatic density and nice-step selection.

Source

pub const fn is_automatic(&self) -> bool

Inspect whether the complete request is Automatic without an explicit cap.

Source

pub fn additive(step: f64) -> Result<TickGeneration, Error>

Prefer a finite strictly positive additive step on a linear numeric axis.

Source

pub fn log10_decades(decades: u32) -> Result<TickGeneration, Error>

Prefer a nonzero integral exponent step on a base-ten logarithmic axis.

Source

pub fn interval( step: f64, origin: f64, space: TickSpace, requirement: TickRequirement, ) -> Result<TickGeneration, Error>

Select a finite positive interval and finite origin in the declared space.

Source

pub const fn interval_parameters( &self, ) -> Option<(f64, f64, TickSpace, TickRequirement)>

Inspect the retained step, origin, coordinate space and source requirement.

Source

pub fn multiplicative( anchor: f64, ratio: f64, requirement: TickRequirement, ) -> Result<TickGeneration, Error>

Select the positive anchored geometric lattice, retaining either ratio direction.

Source

pub const fn multiplicative_parameters( &self, ) -> Option<(f64, f64, TickRequirement)>

Inspect the supplied anchor, ratio direction and complete-source requirement.

Source

pub fn target(count: usize) -> Result<TickGeneration, Error>

Request approximately count numeric positions, allowing nice-step deviation.

Counts must be positive; one requests the original-domain midpoint. Actual label fit can select a coarser complete source.

Source

pub fn maximum(count: usize) -> Result<TickGeneration, Error>

Bound generated in-domain positions, including endpoints, by count.

Counts must be positive. The bound applies to complete generated sources, not exact caller ticks; it never drops individual labels.

Source

pub const fn target_count(&self) -> Option<usize>

Inspect the target count, or None for another selection.

Source

pub const fn get_maximum_count(&self) -> Option<usize>

Inspect the hard maximum count, or None for another selection.

Source

pub fn maximum_count( self, maximum: Option<usize>, ) -> Result<TickGeneration, Error>

Set or clear the positive generated cap, without replacing the locator.

Source

pub const fn exact_count(count: usize, space: TickSpace) -> TickGeneration

Generate exactly count positions; zero is empty and one initially uses Lower.

Source

pub fn singleton(self, position: TickSingleton) -> Result<TickGeneration, Error>

Set exact-count singleton placement, retaining the complete request for n>=2.

Source

pub const fn additive_step(&self) -> Option<f64>

Inspect the positive additive step, or None for another selection.

Source

pub const fn decade_step(&self) -> Option<u32>

Inspect the positive integral decade step, or None for another selection.

Trait Implementations§

Source§

impl Clone for TickGeneration

Source§

fn clone(&self) -> TickGeneration

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 TickGeneration

Source§

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

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

impl Default for TickGeneration

Source§

fn default() -> TickGeneration

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

impl Eq for TickGeneration

Source§

impl PartialEq for TickGeneration

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TickGeneration

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

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 = !

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V