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

source

pub fn new() -> Box<dyn IWorkByProxy>

Constructor

Returns

Returns a new instance of the ProxyEntity struct as implemented by the IWorkByProxy trait.

source

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.

Trait Implementations§

source§

impl IWorkByProxy for ProxyEntity

source§

fn do_work(&mut self, some_argument: &str) -> String

Does some work on the given argument and returns a new string.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V