Skip to content

How do I return a Stream from a server function? #3210

Answered by benwis
eliaxelang007 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi eliaxelang007!
You'll want to take a look at our server fns example here:

#[server(output = StreamingText)]

The available codes are in the docs for the server_fn crate, I think you're looking for this one:
https://docs.rs/server_fn/latest/server_fn/codec/struct.ByteStream.html

The short of it is to set the output encoding to Streaming, and then return the ByteStream type, much like the example does with TextStream.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@eliaxelang007
Comment options

@benwis
Comment options

Answer selected by eliaxelang007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants