Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seal the VertexInfo and InternalVertexInfo traits. #227

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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