Skip to content

Commit

Permalink
Seal the VertexInfo and InternalVertexInfo traits. (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Mar 31, 2023
1 parent 14ba029 commit 1ecd1ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions trustfall_core/src/interpreter/hints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::ir::{
};

mod candidates;
mod sealed;
mod vertex_info;

pub use candidates::CandidateValue;
Expand Down Expand Up @@ -75,6 +76,9 @@ impl ResolveInfo {
}
}

impl sealed::__Sealed for ResolveInfo {}
impl sealed::__Sealed for NeighborInfo {}

impl InternalVertexInfo for ResolveInfo {
#[inline]
fn current_vertex(&self) -> &IRVertex {
Expand Down
1 change: 1 addition & 0 deletions trustfall_core/src/interpreter/hints/sealed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub trait __Sealed {}
6 changes: 3 additions & 3 deletions trustfall_core/src/interpreter/hints/vertex_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::EdgeInfo;

/// Information about what the currently-executing query needs at a specific vertex.
#[cfg_attr(docsrs, doc(notable_trait))]
pub trait VertexInfo {
pub trait VertexInfo: super::sealed::__Sealed {
/// The unique ID of the vertex this [`VertexInfo`] describes.
fn vid(&self) -> Vid;

Expand Down Expand Up @@ -38,7 +38,7 @@ pub trait VertexInfo {
fn edges_with_name<'a>(&'a self, name: &'a str) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>;
}

pub(super) trait InternalVertexInfo {
pub(super) trait InternalVertexInfo: super::sealed::__Sealed {
fn current_vertex(&self) -> &IRVertex;

fn current_component(&self) -> &IRQueryComponent;
Expand All @@ -48,7 +48,7 @@ pub(super) trait InternalVertexInfo {
fn make_folded_edge_info(&self, fold: &IRFold) -> EdgeInfo;
}

impl<T: InternalVertexInfo> VertexInfo for T {
impl<T: InternalVertexInfo + super::sealed::__Sealed> VertexInfo for T {
fn vid(&self) -> Vid {
self.current_vertex().vid
}
Expand Down

0 comments on commit 1ecd1ff

Please sign in to comment.