Trait shipyard::Borrow

source ·
pub trait Borrow<'a> {
    type View;

    // Required method
    fn borrow(
        world: &'a World,
        last_run: Option<u32>,
        current: u32,
    ) -> Result<Self::View, GetStorage>;
}
Expand description

Allows a type to be borrowed by World::borrow, World::run and workloads.

§Example of manual implementation:

use shipyard::{Borrow, IntoBorrow, View, UniqueView, World};

struct CameraView<'v> {
    camera: UniqueView<'v, Camera>,
    position: View<'v, Position>,
}
// There shouldn't be any lifetime on this struct.
// If the custom view has generics, PhantomData can be used to make the compiler happy.
struct CameraViewBorrower {}

impl<'v> Borrow<'v> for CameraViewBorrower {
    type View = CameraView<'v>;

    fn borrow(
        world: &'v World,
        last_run: Option<u32>,
        current: u32,
    ) -> Result<Self::View, shipyard::error::GetStorage> {
        Ok(CameraView {
            camera: <UniqueView<'v, Camera> as IntoBorrow>::Borrow::borrow(world, last_run, current)?,
            position: <View<'v, Position> as IntoBorrow>::Borrow::borrow(world, last_run, current)?,
        })
    }
}

Required Associated Types§

Required Methods§

source

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

This function is where the actual borrowing happens.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, A: Borrow<'a>> Borrow<'a> for (A,)

§

type View = (<A as Borrow<'a>>::View,)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>> Borrow<'a> for (A, B)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>> Borrow<'a> for (A, B, C)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>> Borrow<'a> for (A, B, C, D)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>, E: Borrow<'a>> Borrow<'a> for (A, B, C, D, E)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View, <E as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>, E: Borrow<'a>, F: Borrow<'a>> Borrow<'a> for (A, B, C, D, E, F)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View, <E as Borrow<'a>>::View, <F as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>, E: Borrow<'a>, F: Borrow<'a>, G: Borrow<'a>> Borrow<'a> for (A, B, C, D, E, F, G)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View, <E as Borrow<'a>>::View, <F as Borrow<'a>>::View, <G as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>, E: Borrow<'a>, F: Borrow<'a>, G: Borrow<'a>, H: Borrow<'a>> Borrow<'a> for (A, B, C, D, E, F, G, H)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View, <E as Borrow<'a>>::View, <F as Borrow<'a>>::View, <G as Borrow<'a>>::View, <H as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>, E: Borrow<'a>, F: Borrow<'a>, G: Borrow<'a>, H: Borrow<'a>, I: Borrow<'a>> Borrow<'a> for (A, B, C, D, E, F, G, H, I)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View, <E as Borrow<'a>>::View, <F as Borrow<'a>>::View, <G as Borrow<'a>>::View, <H as Borrow<'a>>::View, <I as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, A: Borrow<'a>, B: Borrow<'a>, C: Borrow<'a>, D: Borrow<'a>, E: Borrow<'a>, F: Borrow<'a>, G: Borrow<'a>, H: Borrow<'a>, I: Borrow<'a>, J: Borrow<'a>> Borrow<'a> for (A, B, C, D, E, F, G, H, I, J)

§

type View = (<A as Borrow<'a>>::View, <B as Borrow<'a>>::View, <C as Borrow<'a>>::View, <D as Borrow<'a>>::View, <E as Borrow<'a>>::View, <F as Borrow<'a>>::View, <G as Borrow<'a>>::View, <H as Borrow<'a>>::View, <I as Borrow<'a>>::View, <J as Borrow<'a>>::View)

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

source§

impl<'a, T: Borrow<'a>> Borrow<'a> for Option<T>

§

type View = Option<<T as Borrow<'a>>::View>

source§

fn borrow( world: &'a World, last_run: Option<u32>, current: u32, ) -> Result<Self::View, GetStorage>

Implementors§

source§

impl<'a> Borrow<'a> for AllStoragesBorrower

source§

impl<'a> Borrow<'a> for AllStoragesMutBorrower

source§

impl<'a> Borrow<'a> for EntitiesBorrower

§

type View = EntitiesView<'a>

source§

impl<'a> Borrow<'a> for EntitiesMutBorrower

source§

impl<'a> Borrow<'a> for UnitBorrower

§

type View = ()

source§

impl<'a, T: Send + Sync + Component> Borrow<'a> for ViewBorrower<T>
where T::Tracking: Send + Sync,

§

type View = View<'a, T>

source§

impl<'a, T: Send + Sync + Component> Borrow<'a> for ViewMutBorrower<T>
where T::Tracking: Send + Sync,

§

type View = ViewMut<'a, T>

source§

impl<'a, T: Send + Sync + Unique> Borrow<'a> for UniqueViewBorrower<T>

§

type View = UniqueView<'a, T>

source§

impl<'a, T: Send + Sync + Unique> Borrow<'a> for UniqueViewMutBorrower<T>

§

type View = UniqueViewMut<'a, T>

source§

impl<'a, T: Send + Component> Borrow<'a> for NonSync<ViewBorrower<T>>
where T::Tracking: Send,

§

type View = NonSync<View<'a, T>>

source§

impl<'a, T: Send + Component> Borrow<'a> for NonSync<ViewMutBorrower<T>>
where T::Tracking: Send,

§

type View = NonSync<ViewMut<'a, T>>

source§

impl<'a, T: Send + Unique> Borrow<'a> for NonSync<UniqueViewBorrower<T>>

§

type View = NonSync<UniqueView<'a, T>>

source§

impl<'a, T: Send + Unique> Borrow<'a> for NonSync<UniqueViewMutBorrower<T>>

source§

impl<'a, T: Sync + Component> Borrow<'a> for NonSend<ViewBorrower<T>>
where T::Tracking: Sync,

§

type View = NonSend<View<'a, T>>

source§

impl<'a, T: Sync + Component> Borrow<'a> for NonSend<ViewMutBorrower<T>>
where T::Tracking: Sync,

§

type View = NonSend<ViewMut<'a, T>>

source§

impl<'a, T: Sync + Unique> Borrow<'a> for NonSend<UniqueViewBorrower<T>>

§

type View = NonSend<UniqueView<'a, T>>

source§

impl<'a, T: Sync + Unique> Borrow<'a> for NonSend<UniqueViewMutBorrower<T>>

source§

impl<'a, T: Component> Borrow<'a> for NonSendSync<ViewBorrower<T>>

§

type View = NonSendSync<View<'a, T>>

source§

impl<'a, T: Component> Borrow<'a> for NonSendSync<ViewMutBorrower<T>>

§

type View = NonSendSync<ViewMut<'a, T>>

source§

impl<'a, T: Unique> Borrow<'a> for NonSendSync<UniqueViewBorrower<T>>

source§

impl<'a, T: Unique> Borrow<'a> for NonSendSync<UniqueViewMutBorrower<T>>