blob: 25a7d8e8b365047dbe42fed1eae622f002033574 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package com.softwaremill.sttp.testing
import com.softwaremill.sttp.Id
import scala.concurrent.Future
import scala.language.higherKinds
import scala.util.Try
trait ConvertToFuture[R[_]] {
def toFuture[T](value: R[T]): Future[T]
}
object ConvertToFuture {
val id: ConvertToFuture[Id] = new ConvertToFuture[Id] {
override def toFuture[T](value: Id[T]): Future[T] =
Future.successful(value)
}
val future: ConvertToFuture[Future] = new ConvertToFuture[Future] {
override def toFuture[T](value: Future[T]): Future[T] = value
}
val scalaTry: ConvertToFuture[Try] = new ConvertToFuture[Try] {
override def toFuture[T](value: Try[T]): Future[T] = Future.fromTry(value)
}
}
|