[][src]Trait plexus::graph::PayloadBinding

pub trait PayloadBinding: Deref<Target = Self::Payload> {
    type Key: OpaqueKey;
    type Payload: Payload<Key = Self::Key>;
    fn key(&self) -> Self::Key;

    fn rekey<T, M>(self, key: T::Key) -> Result<T, GraphError>
    where
        Self: Into<View<M, Self::Payload>>,
        T: From<View<M, <T as PayloadBinding>::Payload>> + PayloadBinding,
        M: Reborrow,
        M::Target: AsStorage<Self::Payload> + AsStorage<T::Payload>
, { ... } }

A view into a graph that is bound to a payload by its key.

This trait is implemented by views that operate over a specific topology in a graph, such as a vertex or face. Note that rings and paths are exposed as meta-views, and as such do not implement this trait.

Associated Types

type Key: OpaqueKey

type Payload: Payload<Key = Self::Key>

Loading content...

Required methods

fn key(&self) -> Self::Key

Gets the key for the view.

Loading content...

Provided methods

fn rekey<T, M>(self, key: T::Key) -> Result<T, GraphError> where
    Self: Into<View<M, Self::Payload>>,
    T: From<View<M, <T as PayloadBinding>::Payload>> + PayloadBinding,
    M: Reborrow,
    M::Target: AsStorage<Self::Payload> + AsStorage<T::Payload>, 

Rekeys a view into another.

Rekeying a view allows its underlying storage to be reinterpretted. The output view must also be bound to a payload.

Examples

Perform a fallible traversal and preserve mutability of the resulting view:

// ...
let face = graph.face_mut(key).unwrap();
// Find a face along a boundary. If no such face is found, continue to use the
// initiating face.
let mut face = {
    let key = face
        .traverse_by_depth()
        .find(|face| {
            face.interior_arcs()
                .map(|arc| arc.into_opposite_arc())
                .any(|arc| arc.is_boundary_arc())
        })
        .map(|face| face.key());
    if let Some(key) = key {
        face.rekey(key).unwrap() // Rekey into the boundary face.
    }
    else {
        face
    }
};
Loading content...

Implementors

impl<'a, G> PayloadBinding for ArcOrphan<'a, G> where
    G: 'a + GraphGeometry
[src]

type Key = ArcKey

type Payload = ArcPayload<G>

impl<'a, G> PayloadBinding for EdgeOrphan<'a, G> where
    G: 'a + GraphGeometry
[src]

type Key = EdgeKey

type Payload = EdgePayload<G>

impl<'a, G> PayloadBinding for FaceOrphan<'a, G> where
    G: 'a + GraphGeometry
[src]

type Key = FaceKey

type Payload = FacePayload<G>

impl<'a, G> PayloadBinding for VertexOrphan<'a, G> where
    G: 'a + GraphGeometry
[src]

type Key = VertexKey

type Payload = VertexPayload<G>

impl<M, G> PayloadBinding for ArcView<M, G> where
    M: Reborrow,
    M::Target: AsStorage<ArcPayload<G>>,
    G: GraphGeometry
[src]

type Key = ArcKey

type Payload = ArcPayload<G>

impl<M, G> PayloadBinding for EdgeView<M, G> where
    M: Reborrow,
    M::Target: AsStorage<EdgePayload<G>>,
    G: GraphGeometry
[src]

type Key = EdgeKey

type Payload = EdgePayload<G>

impl<M, G> PayloadBinding for FaceView<M, G> where
    M: Reborrow,
    M::Target: AsStorage<FacePayload<G>>,
    G: GraphGeometry
[src]

type Key = FaceKey

type Payload = FacePayload<G>

impl<M, G> PayloadBinding for VertexView<M, G> where
    M: Reborrow,
    M::Target: AsStorage<VertexPayload<G>>,
    G: GraphGeometry
[src]

type Key = VertexKey

type Payload = VertexPayload<G>

Loading content...