pub struct ProxyEntity {
real_entity: Option<Box<dyn IWorkByProxy>>,
}
Expand description
The proxy entity that implements the IWorkByProxy and forwards the calls on that trait to a real entity, which is instantiated when the do_work() method on the IWorkByProxy trait is first called.
Fields§
§real_entity: Option<Box<dyn IWorkByProxy>>
The one and only instance of the real entity associated with this proxy entity. Initialized with None so it can be filled in later with a pointer to the actual real entity instance.
Implementations§
source§impl ProxyEntity
impl ProxyEntity
sourcepub fn new() -> Box<dyn IWorkByProxy>
pub fn new() -> Box<dyn IWorkByProxy>
Constructor
Returns
Returns a new instance of the ProxyEntity struct as implemented by the IWorkByProxy trait.
sourcepub fn get_real_entity(&mut self) -> &mut Box<dyn IWorkByProxy>
pub fn get_real_entity(&mut self) -> &mut Box<dyn IWorkByProxy>
Helper method to retrieve the one and only instance of the real entity. This hides the details of instantiating the real entity and enforces a “singleton” nature on the instance.
Returns
Returns a reference to the real entity as implemented by the IWorkByProxy trait.