hakuban 0.7.2

Data-object sharing library
Documentation
use super::expose::TagExposeContract;
use crate::{LocalExchange, TagDescriptor, TagObserveContract};

//TODO: composition cost, desired update frequency

#[must_use = "Call .expose() or .observe() at the end of the build chain."]
pub struct TagContractBuilder {
	local_exchange: LocalExchange,
	descriptor: TagDescriptor,
}


//LockCheck:  scope=TagContractBuilder
impl TagContractBuilder {
	//LockCheck:
	pub(crate) fn new(local_exchange: LocalExchange, descriptor: TagDescriptor) -> TagContractBuilder {
		TagContractBuilder { local_exchange, descriptor }
	}

	//LockCheck:  call=LocalExchange::tag_acquire  call=TagObserveContract::new
	pub fn observe(self) -> TagObserveContract {
		let tag_core = self.local_exchange.shared.tag_acquire(&self.descriptor);
		TagObserveContract::new(self.local_exchange, tag_core)
	}

	//LockCheck:  call=LocalExchange::tag_acquire  call=TagExposeContract::new
	pub fn expose(self) -> TagExposeContract {
		let tag_core = self.local_exchange.shared.tag_acquire(&self.descriptor);
		TagExposeContract::new(self.local_exchange, tag_core, 1000)
	}
}