pub struct StreamerValue {
pub text: String,
pub ast: Comprehension,
pub outer: Vec<String>,
}Expand description
A comprehension bound as a value.
Fields§
§text: StringThe text after for, as the author wrote it (or, for a derived
producer, the derivation text).
ast: ComprehensionThe comprehension, with any derivation already applied.
outer: Vec<String>The names the comprehension reads from the scope its wire is bound in: each is a name of that scope, which a traversal captures when it opens and a stream has none of. Empty for a streamer built from text alone.
Implementations§
Source§impl StreamerValue
impl StreamerValue
Sourcepub fn new(text: impl Into<String>, ast: Comprehension) -> Self
pub fn new(text: impl Into<String>, ast: Comprehension) -> Self
A streamer over ast with its source text, bound in no scope.
Sourcepub fn in_scope(
text: impl Into<String>,
ast: Comprehension,
has: &dyn Fn(&str) -> bool,
) -> Self
pub fn in_scope( text: impl Into<String>, ast: Comprehension, has: &dyn Fn(&str) -> bool, ) -> Self
A streamer over ast bound to a wire of a scope that has the
names has answers true for. Self::outer holds the names the
comprehension reads, does not bind, and the scope has; a name it
reads that the scope does not have is resolved nowhere and reads
None (comprehension_forms.md §5 V3).
Sourcepub fn element_names(&self) -> Vec<String>
pub fn element_names(&self) -> Vec<String>
Element names in tuple order.
Sourcepub fn metadata(&self) -> Metadata
pub fn metadata(&self) -> Metadata
The algebra’s metadata: cardinality, index addressability, and natural order.
Sourcepub fn cardinality(&self) -> CardinalityClass
pub fn cardinality(&self) -> CardinalityClass
The cardinality class of the tuple space.
Sourcepub fn compiled(&self) -> Result<CompiledComprehension, ValidationError>
pub fn compiled(&self) -> Result<CompiledComprehension, ValidationError>
Compile to the shared IR: validation, optimization, then the
AST → IR pass. Each call is independent. A comprehension the
for lowering resolved was validated then and fails here only
when it reads a name of the scope its wire is bound in
(Self::outer), which this surface has none of
(ContextRequired, PredicateContextRequired,
comprehension_forms.md §9.5.2); one built programmatically is
validated here. A name it reads that nothing binds reads None
(§5 V3).
Sourcepub fn coordinate_stream(&self) -> Result<CoordinateStream, ValidationError>
pub fn coordinate_stream(&self) -> Result<CoordinateStream, ValidationError>
A fresh coordinate stream with its own dispense cursor.
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Serialize for transport through a const node argument. The
compiler lowers a producer binding to streamer("<json>").
Sourcepub fn from_json(payload: &str) -> Self
pub fn from_json(payload: &str) -> Self
Build from a node argument: either the JSON payload the compiler
emits for for expressions, or plain comprehension text such as
k in 1..4 when an author calls streamer directly. Panics
with the parser’s diagnostic when neither form applies.
Sourcepub fn parse_text(text: &str) -> Result<Self, String>
pub fn parse_text(text: &str) -> Result<Self, String>
Parse canonical comprehension text into a streamer value.
Trait Implementations§
Source§impl Clone for StreamerValue
impl Clone for StreamerValue
Source§impl Debug for StreamerValue
impl Debug for StreamerValue
Source§impl<'de> Deserialize<'de> for StreamerValue
impl<'de> Deserialize<'de> for StreamerValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for StreamerValue
impl PartialEq for StreamerValue
Source§impl ReflectedValue for StreamerValue
impl ReflectedValue for StreamerValue
Source§fn display(&self) -> String
fn display(&self) -> String
Source§fn to_json_value(&self) -> Value
fn to_json_value(&self) -> Value
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Source§fn clone_reflected(&self) -> Box<dyn ReflectedValue>
fn clone_reflected(&self) -> Box<dyn ReflectedValue>
Source§fn try_as_str(&self) -> Option<String>
fn try_as_str(&self) -> Option<String>
Source§fn try_as_u64(&self) -> Option<u64>
fn try_as_u64(&self) -> Option<u64>
Source§fn try_as_f64(&self) -> Option<f64>
fn try_as_f64(&self) -> Option<f64>
Source§fn try_as_bytes(&self) -> Option<&[u8]>
fn try_as_bytes(&self) -> Option<&[u8]>
Source§impl Serialize for StreamerValue
impl Serialize for StreamerValue
impl StructuralPartialEq for StreamerValue
Auto Trait Implementations§
impl Freeze for StreamerValue
impl RefUnwindSafe for StreamerValue
impl Send for StreamerValue
impl Sync for StreamerValue
impl Unpin for StreamerValue
impl UnsafeUnpin for StreamerValue
impl UnwindSafe for StreamerValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more