Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: STTP stream #880

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions kyo-core/jvm/src/main/scala/kyo/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Path private (val path: List[String]) derives CanEqual:
end if
}

private def readLoop[A, ReadTpe, Res](
private[kyo] def readLoop[A, ReadTpe, Res](
acquire: Res < IO,
release: Res => Unit < Async,
readOnce: Res => Maybe[ReadTpe] < IO,
Expand Down Expand Up @@ -358,14 +358,17 @@ object Path:
case s: String => List(s)
case p: Path => p.path
}
val javaPath = if flattened.isEmpty then Paths.get("") else Paths.get(flattened.head, flattened.tail*)
val normalizedPath = javaPath.normalize().toString
new Path(if normalizedPath.isEmpty then Nil else normalizedPath.split(File.separator).toList)
val javaPath = if flattened.isEmpty then Paths.get("") else Paths.get(flattened.head, flattened.tail*)
fromJavaPath(javaPath)
end apply

def apply(path: Part*): Path =
apply(path.toList)

def fromJavaPath(path: JPath): Path =
val normalizedPath = path.normalize().toString
new Path(if normalizedPath.isEmpty then Nil else normalizedPath.split(File.separator).toList)

case class BasePaths(
cache: Path,
config: Path,
Expand Down
14 changes: 14 additions & 0 deletions kyo-sttp/jvm/src/main/scala/kyo/capabilities/KyoStreams.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kyo.capabilities

import kyo.Abort
import kyo.Async
import kyo.IO
import kyo.Resource
import kyo.Stream
import sttp.capabilities.Streams

trait KyoStreams extends Streams[KyoStreams]:
override type BinaryStream = Stream[Byte, Async & Resource]
override type Pipe[A, B] = Stream[A, Async & Resource] => Stream[B, Async & Resource]

object KyoStreams extends KyoStreams
Loading
Loading