| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Servant.API.Stream
Synopsis
- data Stream (method :: k1) (status :: Nat) framing contentType a
- type StreamGet = Stream 'GET 200
- type StreamPost = Stream 'POST 200
- type StreamBody = StreamBody' ('[] :: [Type])
- data StreamBody' (mods :: [Type]) framing contentType a
- type SourceIO = SourceT IO
- class ToSourceIO chunk a | a -> chunk where
- toSourceIO :: a -> SourceIO chunk
- class FromSourceIO chunk a | a -> chunk where
- fromSourceIO :: SourceIO chunk -> IO a
- class SourceToSourceIO (m :: Type -> Type) where
- sourceToSourceIO :: SourceT m a -> SourceT IO a
- class FramingRender (strategy :: k) where
- framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString
- class FramingUnrender (strategy :: k) where
- framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a
- data NoFraming
- data NewlineFraming
- data NetstringFraming
Documentation
data Stream (method :: k1) (status :: Nat) framing contentType a #
A Stream endpoint for a given method emits a stream of encoded values at a
given Content-Type, delimited by a framing strategy.
Type synonyms are provided for standard methods.
Instances
| HasLink (Stream m status fr ct a :: Type) # | |
| Generic (Stream method status framing contentType a) # | |
Defined in Servant.API.Stream | |
| type MkLink (Stream m status fr ct a :: Type) r # | |
Defined in Servant.Links | |
| type Rep (Stream method status framing contentType a) # | |
type StreamPost = Stream 'POST 200 #
type StreamBody = StreamBody' ('[] :: [Type]) #
A stream request body.
data StreamBody' (mods :: [Type]) framing contentType a #
Instances
| HasLink sub => HasLink (StreamBody' mods framing ct a :> sub :: Type) # | |||||
Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (StreamBody' mods framing ct a :> sub) -> Link -> MkLink (StreamBody' mods framing ct a :> sub) a0 # | |||||
| Generic (StreamBody' mods framing contentType a) # | |||||
Defined in Servant.API.Stream Associated Types
Methods from :: StreamBody' mods framing contentType a -> Rep (StreamBody' mods framing contentType a) x # to :: Rep (StreamBody' mods framing contentType a) x -> StreamBody' mods framing contentType a # | |||||
| type MkLink (StreamBody' mods framing ct a :> sub :: Type) r # | |||||
Defined in Servant.Links | |||||
| type Rep (StreamBody' mods framing contentType a) # | |||||
Defined in Servant.API.Stream | |||||
Source
SourceIO are equivalent to some *source* in streaming libraries.
class ToSourceIO chunk a | a -> chunk where #
ToSourceIO is intended to be implemented for types such as Conduit, Pipe,
etc. By implementing this class, all such streaming abstractions can be used
directly as endpoints.
Methods
toSourceIO :: a -> SourceIO chunk #
Instances
| ToSourceIO a (NonEmpty a) # | |
Defined in Servant.API.Stream Methods toSourceIO :: NonEmpty a -> SourceIO a # | |
| ToSourceIO a [a] # | |
Defined in Servant.API.Stream Methods toSourceIO :: [a] -> SourceIO a # | |
| SourceToSourceIO m => ToSourceIO chunk (SourceT m chunk) # | Relax to use auxiliary class, have m |
Defined in Servant.API.Stream Methods toSourceIO :: SourceT m chunk -> SourceIO chunk # | |
class FromSourceIO chunk a | a -> chunk where #
FromSourceIO is intended to be implemented for types such as Conduit,
Pipe, etc. By implementing this class, all such streaming abstractions can
be used directly on the client side for talking to streaming endpoints.
Methods
fromSourceIO :: SourceIO chunk -> IO a #
Instances
| MonadIO m => FromSourceIO a (SourceT m a) # | |
Defined in Servant.API.Stream Methods fromSourceIO :: SourceIO a -> IO (SourceT m a) # | |
Auxiliary classes
class SourceToSourceIO (m :: Type -> Type) where #
Auxiliary class for instance.ToSourceIO x (SourceT m x)
Methods
sourceToSourceIO :: SourceT m a -> SourceT IO a #
Instances
| SourceToSourceIO IO # | |
Defined in Servant.API.Stream | |
Framing
class FramingRender (strategy :: k) where #
The FramingRender class provides the logic for emitting a framing strategy.
The strategy transforms a into SourceT m a,
therefore it can prepend, append and intercalate framing structure
around chunks.SourceT m ByteString
Note: as the is generic, this is pure transformation.Monad m
Methods
framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString #
Instances
| FramingRender NetstringFraming # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString # | |
| FramingRender NewlineFraming # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString # | |
| FramingRender NoFraming # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString # | |
class FramingUnrender (strategy :: k) where #
The FramingUnrender class provides the logic for parsing a framing
strategy.
Methods
framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a #
Instances
| FramingUnrender NetstringFraming # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a # | |
| FramingUnrender NewlineFraming # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a # | |
| FramingUnrender NoFraming # | As That works well when |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a # | |
Strategies
A framing strategy that does not do any framing at all, it just passes the input data This will be used most of the time with binary data, such as files
Instances
| FramingRender NoFraming # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString # | |
| FramingUnrender NoFraming # | As That works well when |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a # | |
data NewlineFraming #
A simple framing strategy that has no header, and inserts a newline character after each frame. This assumes that it is used with a Content-Type that encodes without newlines (e.g. JSON).
Instances
| FramingRender NewlineFraming # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString # | |
| FramingUnrender NewlineFraming # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a # | |
data NetstringFraming #
The netstring framing strategy as defined by djb: http://cr.yp.to/proto/netstrings.txt
Any string of 8-bit bytes may be encoded as [len]":"[string]",". Here
[string] is the string and [len] is a nonempty sequence of ASCII digits
giving the length of [string] in decimal. The ASCII digits are 30 for
0, 31 for 1, and so on up through 39 for 9. Extra zeros at the front
of [len] are prohibited: [len] begins with 30 exactly when
[string] is empty.
For example, the string "hello world!" is encoded as
32 3a 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 2c,
i.e., "12:hello world!,".
The empty string is encoded as "0:,".
Instances
| FramingRender NetstringFraming # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString # | |
| FramingUnrender NetstringFraming # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a # | |