pub struct StreamingFieldResolver;Expand description
Shared streaming-virtual-fields resolver for e2e test codegen.
Implementations§
Source§impl StreamingFieldResolver
impl StreamingFieldResolver
Sourcepub fn accessor(field: &str, lang: &str, chunks_var: &str) -> Option<String>
pub fn accessor(field: &str, lang: &str, chunks_var: &str) -> Option<String>
Returns the language-specific expression for a streaming-virtual field,
given chunks_var (the collected-list local name) and lang.
Returns None when the field name is not a known streaming-virtual
field or the language has no streaming support.
module_qualifier carries the per-project module/crate name used by the
Rust and C# stream.has_*_event branches to construct the streaming
union type path. Pass the cargo crate name (snake_case) for Rust callers
and the C# namespace (PascalCase) for C# callers. When None is
supplied for those branches, the accessor returns None so the call
site can skip the assertion rather than emit code referencing an unknown
type.
Sourcepub fn accessor_with_module_qualifier(
field: &str,
lang: &str,
chunks_var: &str,
module_qualifier: Option<&str>,
) -> Option<String>
pub fn accessor_with_module_qualifier( field: &str, lang: &str, chunks_var: &str, module_qualifier: Option<&str>, ) -> Option<String>
Same as Self::accessor but accepts a per-project module qualifier
for the stream.has_*_event branches that emit a streaming union type
path.
This is a backward-compatible wrapper; it forwards to
Self::accessor_with_streaming_context with the legacy default item
type "CrawlEvent" so existing callers continue to emit correct code for
kreuzcrawl without changes. Consumers whose streaming union type differs
should call Self::accessor_with_streaming_context directly.
Sourcepub fn accessor_with_streaming_context(
field: &str,
lang: &str,
chunks_var: &str,
module_qualifier: Option<&str>,
item_type: Option<&str>,
) -> Option<String>
pub fn accessor_with_streaming_context( field: &str, lang: &str, chunks_var: &str, module_qualifier: Option<&str>, item_type: Option<&str>, ) -> Option<String>
Same as Self::accessor_with_module_qualifier but also accepts the
unqualified name of the streaming union item type (e.g. "CrawlEvent"
for kreuzcrawl, or any other tagged-union name a consumer defines).
When item_type is None the stream.has_*_event branches fall back
to the legacy default supplied by the originating consumer — callers
that do not know their item type should pass None and the function
returns None for those branches, so the assertion is skipped rather
than emitting a reference to an unknown type.
Sourcepub fn collect_snippet(
lang: &str,
stream_var: &str,
chunks_var: &str,
) -> Option<String>
pub fn collect_snippet( lang: &str, stream_var: &str, chunks_var: &str, ) -> Option<String>
Returns the language-specific stream-collect-into-list snippet that
produces chunks_var from stream_var.
Returns None when the language has no streaming collect support or
when the collect snippet cannot be expressed generically.
Sourcepub fn collect_snippet_typed(
lang: &str,
stream_var: &str,
chunks_var: &str,
item_type: Option<&str>,
) -> Option<String>
pub fn collect_snippet_typed( lang: &str, stream_var: &str, chunks_var: &str, item_type: Option<&str>, ) -> Option<String>
Collect stream into a list, with optional item_type for languages that need the concrete type.
When item_type is None, defaults to ChatCompletionChunk for backward compatibility with liter-llm. For other projects like kreuzcrawl, item_type should be provided (e.g., “CrawlEvent”).