Skip to content

Commit

Permalink
Renamed LazyList to Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 24, 2025
1 parent 3dbca1d commit 07d83e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/core/gesticulate.Content.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
package gesticulate

import anticipation.*
import rudiments.*

case class Content(media: MediaType, stream: LazyList[Bytes])
case class Content(media: MediaType, stream: Stream[Bytes])
16 changes: 8 additions & 8 deletions src/core/gesticulate.Multipart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ object Multipart:
conduit.next()
headers((key, value) :: list)

def body(): LazyList[Bytes] = conduit.step() match
def body(): Stream[Bytes] = conduit.step() match
case Conduit.State.Clutch =>
val block = conduit.block
conduit.cue()
block #:: body()
case Conduit.State.End =>
LazyList()
Stream()
case Conduit.State.Data => conduit.datum match
case '\r' =>
if conduit.lookahead:
conduit.next() && conduit.datum == '\n' && boundary.forall: char =>
conduit.next() && conduit.datum == char
then
conduit.breakBefore()
LazyList(conduit.block).also:
Stream(conduit.block).also:
conduit.skip(boundary.length + 3)
else body()
case other =>
body()

def parsePart(headers: Map[Text, Text], stream: LazyList[Bytes]): Part =
def parsePart(headers: Map[Text, Text], stream: Stream[Bytes]): Part =
headers.at(t"Content-Disposition").let: disposition =>
val parts = disposition.cut(t";").map(_.trim)

Expand Down Expand Up @@ -119,7 +119,7 @@ object Multipart:

. or(Part(Multipart.Disposition.FormData, Map(), Unset, Unset, stream))

def parts(): LazyList[Part] =
def parts(): Stream[Part] =
val part = parsePart(headers(Nil), body())

conduit.datum match
Expand All @@ -137,13 +137,13 @@ object Multipart:
if !conduit.next() || conduit.datum != '\n'
then raise(MultipartError(Reason.Expected('\n')))
//if conduit.next() then raise(MultipartError(Reason.StreamContinues))
LazyList(part)
Stream(part)

case other =>
raise(MultipartError(Reason.Expected('-')))
LazyList()
Stream()

Multipart(parts())

case class Multipart(parts: LazyList[Part]):
case class Multipart(parts: Stream[Part]):
def at(name: Text): Optional[Part] = parts.find(_.name == name).getOrElse(Unset)
2 changes: 1 addition & 1 deletion src/core/gesticulate.Part.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ case class Part
headers: Map[Text, Text],
name: Optional[Text],
filename: Optional[Text],
body: LazyList[Bytes])
body: Stream[Bytes])

0 comments on commit 07d83e6

Please sign in to comment.