pub struct TargetMapBuilder { /* private fields */ }Expand description
Accumulates target expressions into a TargetMap, one unit per distinct
port specification for as long as that is worth doing.
Built incrementally, so an importer can stream a file of any size and decide what to do with a refused expression.
Grouping is abandoned on input that does not group; see MIN_REGROUPED_SHARE and
the module documentation.
Implementations§
Source§impl TargetMapBuilder
impl TargetMapBuilder
Sourcepub fn new(default_ports: PortSet) -> Self
pub fn new(default_ports: PortSet) -> Self
Starts a builder whose expressions take default_ports when they name
no ports of their own.
Sourcepub fn push(
&mut self,
token: &str,
ctx: &TargetContext<'_>,
) -> Result<(), TargetParseError>
pub fn push( &mut self, token: &str, ctx: &TargetContext<'_>, ) -> Result<(), TargetParseError>
Parses one target expression and adds what it names.
Nothing is added when the expression is refused.
Sourcepub fn group_count(&self) -> usize
pub fn group_count(&self) -> usize
How many groups have accumulated.
The number of units build will produce: on input that groups,
the number of distinct port specifications; otherwise, roughly the number of
expressions accepted. See the module documentation.
Sourcepub fn address_count(&mut self) -> u128
pub fn address_count(&mut self) -> u128
How many addresses have accumulated across every group, counting an address once per group it appears in.
Merges ranges to answer, so a block counts what it holds. A caller checks a
scan-size budget against this: ::/0 costs nothing to hold and 2^128 addresses
to scan.
Sourcepub fn gross_address_count(&self) -> u128
pub fn gross_address_count(&self) -> u128
How many addresses have accumulated, counted before overlapping expressions are merged.
The constant-time counterpart to address_count, for a
budget checked once per expression. Walking the accumulated ranges instead made
a 65,536-line import take 3.2 s against 6.9 ms, growing with the square of the
line count.
Never lower than the true count, so a budget check errs early.
Trait Implementations§
Source§impl Clone for TargetMapBuilder
impl Clone for TargetMapBuilder
Auto Trait Implementations§
impl Freeze for TargetMapBuilder
impl RefUnwindSafe for TargetMapBuilder
impl Send for TargetMapBuilder
impl Sync for TargetMapBuilder
impl Unpin for TargetMapBuilder
impl UnsafeUnpin for TargetMapBuilder
impl UnwindSafe for TargetMapBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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