Trait timely_container::ContainerBuilder
source · pub trait ContainerBuilder: Default + 'static {
type Container: Container;
// Required methods
fn push<T: PushInto<Self::Container>>(&mut self, item: T)
where Self::Container: PushContainer;
fn push_container(&mut self, container: &mut Self::Container);
fn extract(&mut self) -> Option<&mut Self::Container>;
fn finish(&mut self) -> Option<&mut Self::Container>;
}
Expand description
A type that can build containers from items.
An implementation needs to absorb elements, and later reveal equivalent information chunked into individual containers, but is free to change the data representation to better fit the properties of the container.
The owner extracts data in two ways. The opportunistic Self::extract
method returns
any ready data, but doesn’t need to produce partial outputs. In contrast, Self::finish
needs to produce all outputs, even partial ones.
For example, a consolidating builder can aggregate differences in-place, but it has to ensure that it preserves the intended information.
The trait does not prescribe any specific ordering guarantees, and each implementation can
decide to represent a push
/push_container
order for extract
and finish
, or not.
Required Associated Types§
Required Methods§
sourcefn push<T: PushInto<Self::Container>>(&mut self, item: T)where
Self::Container: PushContainer,
fn push<T: PushInto<Self::Container>>(&mut self, item: T)where
Self::Container: PushContainer,
Add an item to a container.
sourcefn push_container(&mut self, container: &mut Self::Container)
fn push_container(&mut self, container: &mut Self::Container)
Push a pre-built container.