├── .git-blame-ignore-revs ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── pull_request_template.md └── workflows │ ├── ci.yml │ └── clean.yml ├── .gitignore ├── .sbtopts ├── .scalafmt.conf ├── CHANGELOG.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── LICENSE ├── README.md ├── SECURITY.md ├── benchmark └── src │ └── main │ └── scala │ └── fs2 │ └── benchmark │ ├── ByteBufferChunkBenchmark.scala │ ├── ChannelBenchmark.scala │ ├── ChunkBenchmark.scala │ ├── ChunkFlatten.scala │ ├── ChunksBenchmark.scala │ ├── CompressionBenchmark.scala │ ├── ConcurrentBenchmark.scala │ ├── FlowInteropBenchmark.scala │ ├── GroupWithinBenchmark.scala │ ├── LinesBenchmark.scala │ ├── ParEvalMapBenchmark.scala │ ├── PullBenchmark.scala │ ├── RangeFoldBenchmark.scala │ ├── StreamBenchmark.scala │ └── TextBenchmark.scala ├── build-site.md ├── build.sbt ├── core ├── js │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ ├── ChunkRuntimePlatform.scala │ │ │ ├── compression │ │ │ ├── CompressionPlatform.scala │ │ │ └── GunzipResult.scala │ │ │ ├── hash.scala │ │ │ └── hashing │ │ │ └── HasherCompanionPlatform.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ ├── ChunkRuntimePlatformSuite.scala │ │ ├── TestPlatform.scala │ │ └── hashing │ │ └── HashingSuitePlatform.scala ├── jvm-native │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ └── compression │ │ │ ├── CompressionPlatform.scala │ │ │ └── GunzipResult.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ └── compression │ │ └── JvmNativeCompressionSuite.scala ├── jvm │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ ├── ChunkRuntimePlatform.scala │ │ │ ├── hash.scala │ │ │ ├── hashing │ │ │ └── HasherCompanionPlatform.scala │ │ │ └── internal │ │ │ ├── AsyncByteArrayInputStream.scala │ │ │ └── ThreadFactories.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ ├── TestPlatform.scala │ │ ├── hashing │ │ └── HashingSuitePlatform.scala │ │ └── interop │ │ └── flow │ │ ├── PublisherSpec.scala │ │ └── SubscriberSpec.scala ├── native │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ ├── ChunkRuntimePlatform.scala │ │ │ ├── hash.scala │ │ │ └── hashing │ │ │ └── HasherCompanionPlatform.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ ├── TestPlatform.scala │ │ └── hashing │ │ └── HashingSuitePlatform.scala └── shared │ └── src │ ├── main │ ├── scala-2.12 │ │ └── fs2 │ │ │ ├── ChunkPlatform.scala │ │ │ ├── CollectorPlatform.scala │ │ │ ├── PartiallyAppliedFromBlockingIteratorCrossCompat.scala │ │ │ └── internal │ │ │ └── package.scala │ ├── scala-2.13+ │ │ └── fs2 │ │ │ ├── Chunk213And3Compat.scala │ │ │ └── PartiallyAppliedFromBlockingIteratorCrossCompat.scala │ ├── scala-2.13 │ │ ├── fs2 │ │ │ ├── ChunkPlatform.scala │ │ │ └── CollectorPlatform.scala │ │ └── internal │ │ │ └── package.scala │ ├── scala-2 │ │ └── fs2 │ │ │ └── compat │ │ │ └── NotGiven.scala │ ├── scala-3 │ │ ├── fs2 │ │ │ ├── ChunkPlatform.scala │ │ │ ├── CollectorPlatform.scala │ │ │ └── compat │ │ │ │ └── NotGiven.scala │ │ └── internal │ │ │ └── package.scala │ └── scala │ │ └── fs2 │ │ ├── Chunk.scala │ │ ├── Collector.scala │ │ ├── Compiler.scala │ │ ├── CompositeFailure.scala │ │ ├── Fallible.scala │ │ ├── Pull.scala │ │ ├── RaiseThrowable.scala │ │ ├── Scan.scala │ │ ├── Stream.scala │ │ ├── compression │ │ ├── Compression.scala │ │ ├── DeflateParams.scala │ │ ├── InflateParams.scala │ │ ├── ZLibParams.scala │ │ └── checksum.scala │ │ ├── concurrent │ │ ├── Channel.scala │ │ ├── Signal.scala │ │ ├── Topic.scala │ │ └── concurrent.scala │ │ ├── fs2.scala │ │ ├── hashing │ │ ├── Hash.scala │ │ ├── HashAlgorithm.scala │ │ ├── HashVerificationException.scala │ │ ├── Hasher.scala │ │ └── Hashing.scala │ │ ├── internal │ │ ├── AcquireAfterScopeClosed.scala │ │ ├── InterruptContext.scala │ │ ├── Lease.scala │ │ ├── Scope.scala │ │ └── ScopedResource.scala │ │ ├── interop │ │ └── flow │ │ │ ├── ProcessorPipe.scala │ │ │ ├── StreamProcessor.scala │ │ │ ├── StreamPublisher.scala │ │ │ ├── StreamSubscriber.scala │ │ │ ├── StreamSubscription.scala │ │ │ ├── package.scala │ │ │ └── syntax.scala │ │ ├── text.scala │ │ └── timeseries │ │ ├── TimeSeries.scala │ │ └── TimeStamped.scala │ └── test │ ├── scala-2.12 │ └── fs2 │ │ └── ChunkGeneratorsCompat.scala │ ├── scala-2.13 │ └── fs2 │ │ ├── ArraySeqCollectorSuite.scala │ │ ├── BitSetCollectorSuite.scala │ │ ├── ChunkGeneratorsCompat.scala │ │ └── ChunkPlatformSuite.scala │ ├── scala-3 │ └── fs2 │ │ ├── ChunkGeneratorsCompat.scala │ │ └── Scala3Suite.scala │ └── scala │ └── fs2 │ ├── BracketSuite.scala │ ├── ChecksumSuite.scala │ ├── ChunkGenerators.scala │ ├── ChunkQueueSuite.scala │ ├── ChunkSuite.scala │ ├── CompilationTest.scala │ ├── CompositeFailureSuite.scala │ ├── CompressionSuite.scala │ ├── Counter.scala │ ├── Err.scala │ ├── Fs2Suite.scala │ ├── Generators.scala │ ├── HashSuite.scala │ ├── ListParJoinSuite.scala │ ├── Logger.scala │ ├── MiscellaneousGenerators.scala │ ├── ParEvalMapSuite.scala │ ├── PullLawsSuite.scala │ ├── PullSuite.scala │ ├── StreamAlignSuite.scala │ ├── StreamCombinatorsSuite.scala │ ├── StreamConcurrentlySuite.scala │ ├── StreamConflateSuite.scala │ ├── StreamInterruptSuite.scala │ ├── StreamLawsSuite.scala │ ├── StreamMergeSuite.scala │ ├── StreamObserveSuite.scala │ ├── StreamParJoinSuite.scala │ ├── StreamPerformanceSuite.scala │ ├── StreamRetrySuite.scala │ ├── StreamSpawnSuite.scala │ ├── StreamSuite.scala │ ├── StreamSwitchMapSuite.scala │ ├── StreamTranslateSuite.scala │ ├── StreamZipSuite.scala │ ├── TextSuite.scala │ ├── TimedPullsSuite.scala │ ├── concurrent │ ├── BroadcastSuite.scala │ ├── ChannelSuite.scala │ ├── SignalSuite.scala │ └── TopicSuite.scala │ ├── hashing │ └── HashingSuite.scala │ ├── interop │ └── flow │ │ ├── CancellationSpec.scala │ │ ├── ProcessorPipeSpec.scala │ │ ├── PublisherToSubscriberSpec.scala │ │ ├── StreamProcessorSpec.scala │ │ └── SubscriberStabilitySpec.scala │ └── timeseries │ ├── TimeSeriesSuite.scala │ └── TimeStampedSuite.scala ├── docs ├── implementation-notes.markdown ├── migration-guide-0.10.md ├── migration-guide-0.9.md └── migration-guide-1.0.md ├── flake.lock ├── flake.nix ├── integration └── src │ └── test │ └── scala │ └── fs2 │ └── MemoryLeakSpec.scala ├── io ├── js-jvm │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ └── io │ │ │ └── net │ │ │ ├── Datagram.scala │ │ │ ├── DatagramSocket.scala │ │ │ ├── DatagramSocketGroup.scala │ │ │ └── Network.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ └── io │ │ └── net │ │ └── udp │ │ └── UdpSuite.scala ├── js-native │ └── src │ │ └── main │ │ └── scala │ │ └── fs2 │ │ └── io │ │ └── net │ │ └── unixsocket │ │ └── UnixSocketAddressPlatform.scala ├── js │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ └── io │ │ │ ├── IOException.scala │ │ │ ├── NodeStream.scala │ │ │ ├── compressionplatform.scala │ │ │ ├── file │ │ │ ├── CopyFlag.scala │ │ │ ├── FileHandlePlatform.scala │ │ │ ├── FileSystemException.scala │ │ │ ├── FilesPlatform.scala │ │ │ ├── Flag.scala │ │ │ ├── Path.scala │ │ │ ├── PermissionsPlatform.scala │ │ │ ├── PosixFileKey.scala │ │ │ ├── ReadCursorPlatform.scala │ │ │ └── WriteCursorPlatform.scala │ │ │ ├── internal │ │ │ ├── SuspendedStream.scala │ │ │ ├── ThrowableOps.scala │ │ │ └── facade │ │ │ │ ├── child_process.scala │ │ │ │ ├── dgram.scala │ │ │ │ ├── events.scala │ │ │ │ ├── fs.scala │ │ │ │ ├── net.scala │ │ │ │ ├── os.scala │ │ │ │ ├── path.scala │ │ │ │ ├── process.scala │ │ │ │ ├── stream.scala │ │ │ │ ├── tls.scala │ │ │ │ └── zlib.scala │ │ │ ├── ioplatform.scala │ │ │ ├── net │ │ │ ├── DatagramSocketGroupPlatform.scala │ │ │ ├── DatagramSocketOption.scala │ │ │ ├── DatagramSocketPlatform.scala │ │ │ ├── NetException.scala │ │ │ ├── NetworkPlatform.scala │ │ │ ├── SocketGroupPlatform.scala │ │ │ ├── SocketOptionPlatform.scala │ │ │ ├── SocketPlatform.scala │ │ │ ├── tls │ │ │ │ ├── SSLException.scala │ │ │ │ ├── SSLSession.scala │ │ │ │ ├── SecureContext.scala │ │ │ │ ├── TLSContextPlatform.scala │ │ │ │ ├── TLSParameters.scala │ │ │ │ └── TLSSocketPlatform.scala │ │ │ └── unixsocket │ │ │ │ └── UnixSocketsPlatform.scala │ │ │ └── process │ │ │ └── ProcessesPlatform.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ └── io │ │ ├── IoPlatformSuite.scala │ │ ├── NodeJSCompressionSuite.scala │ │ ├── file │ │ └── BaseFileSuite.scala │ │ └── net │ │ ├── tcp │ │ └── SocketSuitePlatform.scala │ │ ├── tls │ │ ├── TLSSocketSuite.scala │ │ └── TLSSuite.scala │ │ ├── udp │ │ └── UdpSuitePlatform.scala │ │ └── unixsockets │ │ └── UnixSocketsSuitePlatform.scala ├── jvm-native │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ └── io │ │ │ ├── DeprecatedWatcher.scala │ │ │ ├── compressionplatform.scala │ │ │ ├── file │ │ │ ├── CopyFlag.scala │ │ │ ├── DeprecatedFilesApi.scala │ │ │ ├── FileHandlePlatform.scala │ │ │ ├── FilesPlatform.scala │ │ │ ├── Flag.scala │ │ │ ├── Path.scala │ │ │ ├── PermissionsPlatform.scala │ │ │ ├── ReadCursorPlatform.scala │ │ │ ├── Watcher.scala │ │ │ ├── WriteCursorPlatform.scala │ │ │ └── file.scala │ │ │ ├── iojvmnative.scala │ │ │ ├── net │ │ │ ├── SocketGroupPlatform.scala │ │ │ ├── SocketOptionPlatform.scala │ │ │ ├── SocketPlatform.scala │ │ │ └── net.scala │ │ │ └── process │ │ │ └── ProcessesPlatform.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ └── io │ │ ├── file │ │ └── BaseFileSuite.scala │ │ └── net │ │ └── tcp │ │ └── SocketSuitePlatform.scala ├── jvm │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ └── io │ │ │ ├── JavaInputOutputStream.scala │ │ │ ├── internal │ │ │ ├── PipedStreamBuffer.scala │ │ │ └── Synchronizer.scala │ │ │ ├── ioplatform.scala │ │ │ └── net │ │ │ ├── AsynchronousDatagramSocketGroup.scala │ │ │ ├── DatagramSocketGroupPlatform.scala │ │ │ ├── DatagramSocketPlatform.scala │ │ │ ├── NetworkPlatform.scala │ │ │ ├── SelectingSocket.scala │ │ │ ├── SelectingSocketGroup.scala │ │ │ ├── tls │ │ │ ├── DTLSSocket.scala │ │ │ ├── InputOutputBuffer.scala │ │ │ ├── SSLEngineTaskRunner.scala │ │ │ ├── TLSContextPlatform.scala │ │ │ ├── TLSEngine.scala │ │ │ ├── TLSParameters.scala │ │ │ ├── TLSSocketPlatform.scala │ │ │ └── tls.scala │ │ │ └── unixsocket │ │ │ ├── JdkUnixSockets.scala │ │ │ ├── JnrUnixSockets.scala │ │ │ ├── UnixSocketAddressPlatform.scala │ │ │ └── UnixSocketsPlatform.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ └── io │ │ ├── IoPlatformSuite.scala │ │ ├── JavaInputOutputStreamSuite.scala │ │ ├── file │ │ ├── JvmFilesSuite.scala │ │ ├── WalkBenchmark.scala │ │ └── WatcherSuite.scala │ │ └── net │ │ ├── tls │ │ ├── DTLSSocketSuite.scala │ │ ├── TLSDebugExample.scala │ │ ├── TLSParametersSuite.scala │ │ ├── TLSSocketSuite.scala │ │ └── TLSSuite.scala │ │ ├── udp │ │ └── UdpSuitePlatform.scala │ │ └── unixsocket │ │ └── UnixSocketsSuitePlatform.scala ├── native │ └── src │ │ ├── main │ │ └── scala │ │ │ └── fs2 │ │ │ └── io │ │ │ ├── internal │ │ │ ├── NativeUtil.scala │ │ │ ├── ResizableBuffer.scala │ │ │ ├── SocketHelpers.scala │ │ │ ├── netinet.scala │ │ │ ├── syssocket.scala │ │ │ └── sysun.scala │ │ │ ├── ioplatform.scala │ │ │ └── net │ │ │ ├── FdPollingSocket.scala │ │ │ ├── FdPollingSocketGroup.scala │ │ │ ├── Network.scala │ │ │ ├── NetworkPlatform.scala │ │ │ ├── tls │ │ │ ├── CertAuthType.scala │ │ │ ├── CertChainAndKey.scala │ │ │ ├── S2nConfig.scala │ │ │ ├── S2nConnection.scala │ │ │ ├── SSLException.scala │ │ │ ├── SSLSession.scala │ │ │ ├── TLSContextPlatform.scala │ │ │ ├── TLSParameters.scala │ │ │ ├── TLSSocketPlatform.scala │ │ │ ├── s2n.scala │ │ │ └── s2nutil.scala │ │ │ └── unixsocket │ │ │ ├── FdPollingUnixSockets.scala │ │ │ └── UnixSocketsPlatform.scala │ │ └── test │ │ └── scala │ │ └── fs2 │ │ └── io │ │ └── net │ │ ├── tls │ │ ├── TLSSocketSuite.scala │ │ └── TLSSuite.scala │ │ └── unixsockets │ │ └── UnixSocketsSuitePlatform.scala └── shared │ └── src │ ├── main │ ├── scala-2.12 │ │ └── fs2 │ │ │ └── io │ │ │ └── CollectionCompat.scala │ ├── scala-2.13 │ │ └── fs2 │ │ │ └── io │ │ │ └── CollectionCompat.scala │ ├── scala-3 │ │ └── fs2 │ │ │ └── io │ │ │ └── CollectionCompat.scala │ └── scala │ │ └── fs2 │ │ └── io │ │ ├── compression.scala │ │ ├── file │ │ ├── CopyFlagApi.scala │ │ ├── CopyFlags.scala │ │ ├── FileAttributes.scala │ │ ├── FileHandle.scala │ │ ├── FileKey.scala │ │ ├── Files.scala │ │ ├── FlagApi.scala │ │ ├── Flags.scala │ │ ├── PathApi.scala │ │ ├── PathInfo.scala │ │ ├── Permissions.scala │ │ ├── ReadCursor.scala │ │ ├── WalkOptions.scala │ │ └── WriteCursor.scala │ │ ├── io.scala │ │ ├── net │ │ ├── NetworkLowPriority.scala │ │ ├── Socket.scala │ │ ├── SocketGroup.scala │ │ ├── SocketOption.scala │ │ ├── tls │ │ │ ├── TLSContext.scala │ │ │ ├── TLSLogger.scala │ │ │ └── TLSSocket.scala │ │ └── unixsocket │ │ │ ├── UnixSocketAddress.scala │ │ │ └── UnixSockets.scala │ │ └── process │ │ ├── Process.scala │ │ ├── ProcessBuilder.scala │ │ └── Processes.scala │ └── test │ ├── resources │ ├── cert.pem │ ├── fs2 │ │ └── io │ │ │ └── foo │ ├── key.pem │ ├── keystore.jks │ └── keystore.json │ └── scala │ └── fs2 │ └── io │ ├── IoSuite.scala │ ├── file │ ├── FilesExamples.scala │ ├── FilesSuite.scala │ ├── PathSuite.scala │ └── PosixPermissionsSuite.scala │ ├── net │ ├── tcp │ │ └── SocketSuite.scala │ └── unixsocket │ │ └── UnixSocketsSuite.scala │ └── process │ └── ProcessSuite.scala ├── project ├── build.properties └── plugins.sbt ├── protocols └── shared │ └── src │ ├── main │ ├── scala-2 │ │ └── fs2 │ │ │ └── protocols │ │ │ └── pcapng │ │ │ └── BlockCodec.scala │ ├── scala-3 │ │ └── BlockCodec.scala │ └── scala │ │ └── fs2 │ │ └── protocols │ │ ├── Ip4sCodecs.scala │ │ ├── ethernet │ │ ├── EtherType.scala │ │ └── EthernetFrameHeader.scala │ │ ├── ip │ │ ├── Checksum.scala │ │ ├── IpHeader.scala │ │ ├── Ipv4Header.scala │ │ ├── Ipv6Header.scala │ │ ├── tcp │ │ │ ├── TcpFlags.scala │ │ │ └── TcpHeader.scala │ │ └── udp │ │ │ ├── Datagram.scala │ │ │ └── DatagramHeader.scala │ │ ├── mpeg │ │ ├── Descriptor.scala │ │ ├── MpegError.scala │ │ ├── PesPacket.scala │ │ ├── PesPacketHeader.scala │ │ ├── PesPacketHeaderPrefix.scala │ │ ├── PesStreamId.scala │ │ ├── package.scala │ │ └── transport │ │ │ ├── AdaptationField.scala │ │ │ ├── AdaptationFieldFlags.scala │ │ │ ├── Clock27MHz.scala │ │ │ ├── ContinuityCounter.scala │ │ │ ├── Demultiplexer.scala │ │ │ ├── DemultiplexerError.scala │ │ │ ├── Packet.scala │ │ │ ├── Pid.scala │ │ │ ├── ProgramNumber.scala │ │ │ ├── TransportStreamHeader.scala │ │ │ ├── TransportStreamId.scala │ │ │ └── psi │ │ │ ├── ConditionalAccessTable.scala │ │ │ ├── GroupedSections.scala │ │ │ ├── GroupingError.scala │ │ │ ├── ProgramAssociationTable.scala │ │ │ ├── ProgramMapTable.scala │ │ │ ├── Section.scala │ │ │ ├── SectionAccumulator.scala │ │ │ ├── SectionCodec.scala │ │ │ ├── SectionFragmentCodec.scala │ │ │ ├── SectionHeader.scala │ │ │ ├── Table.scala │ │ │ ├── TableBuilder.scala │ │ │ ├── TransportStreamEvent.scala │ │ │ └── TransportStreamIndex.scala │ │ ├── pcap │ │ ├── CaptureFile.scala │ │ ├── GlobalHeader.scala │ │ ├── LinkType.scala │ │ ├── Record.scala │ │ ├── RecordHeader.scala │ │ └── package.scala │ │ └── pcapng │ │ ├── BodyBlock.scala │ │ ├── ByteOrderMagic.scala │ │ ├── CaptureFile.scala │ │ ├── EnhancedPacketBlock.scala │ │ ├── InterfaceDescriptionBlock.scala │ │ ├── InterfaceStatisticsBlock.scala │ │ ├── Length.scala │ │ ├── NameResolutionBlock.scala │ │ ├── ProcessInformationBlock.scala │ │ ├── SectionHeaderBlock.scala │ │ ├── SimplePacketBlock.scala │ │ ├── UnrecognizedBlock.scala │ │ └── package.scala │ └── test │ └── scala │ └── fs2 │ └── protocols │ ├── PcapMpegExample.scala │ ├── PcapNgExample.scala │ ├── ip │ └── Ipv4HeaderTest.scala │ ├── mpeg │ ├── DescriptorTest.scala │ └── transport │ │ ├── PacketTest.scala │ │ └── psi │ │ ├── GroupingTest.scala │ │ └── SectionCodecTest.scala │ └── pcapng │ └── BlockTest.scala ├── reactive-streams └── src │ ├── main │ └── scala │ │ └── fs2 │ │ └── interop │ │ └── reactivestreams │ │ ├── StreamSubscriber.scala │ │ ├── StreamSubscription.scala │ │ ├── StreamUnicastPublisher.scala │ │ └── package.scala │ └── test │ └── scala │ └── fs2 │ └── interop │ └── reactivestreams │ ├── CancellationSpec.scala │ ├── PublisherToSubscriberSpec.scala │ ├── StreamUnicastPublisherSpec.scala │ ├── SubscriberSpec.scala │ └── SubscriberStabilitySpec.scala ├── scalafix ├── build.sbt ├── input │ └── src │ │ └── main │ │ └── scala │ │ └── fix │ │ ├── AkkaSink.scala │ │ ├── Bracket.scala │ │ ├── Chunk.scala │ │ ├── ConcurrentDataTypes.scala │ │ ├── Fs2sinkremoval.scala │ │ ├── MyAppClass.scala │ │ ├── MyAppObject.scala │ │ ├── Scheduler.scala │ │ └── Usability.scala ├── output │ └── src │ │ └── main │ │ └── scala │ │ └── fix │ │ ├── AkkaSink.scala │ │ ├── Bracket.scala │ │ ├── Chunk.scala │ │ ├── ConcurrentDataTypes.scala │ │ ├── Fs2sinkremoval.scala │ │ ├── MyAppClass.scala │ │ ├── MyAppObject.scala │ │ ├── Scheduler.scala │ │ └── Usability.scala ├── project │ ├── build.properties │ └── plugins.sbt ├── rules │ └── src │ │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── scalafix.v1.Rule │ │ └── scala │ │ └── fix │ │ └── v1.scala └── tests │ └── src │ └── test │ └── scala │ └── fix │ └── RuleSuite.scala ├── scodec └── shared │ └── src │ ├── main │ └── scala │ │ └── fs2 │ │ └── interop │ │ └── scodec │ │ ├── CodecError.scala │ │ ├── StreamDecoder.scala │ │ └── StreamEncoder.scala │ └── test │ └── scala │ └── fs2 │ └── interop │ └── scodec │ ├── ListOfNSuite.scala │ ├── MpegExample.scala │ ├── SpaceLeakTest.scala │ └── StreamCodecSuite.scala ├── site ├── CNAME ├── _coverpage.md ├── _media │ ├── favicon.png │ ├── logo.png │ ├── logo_small.png │ └── stream-and-pull.png ├── _sidebar.md ├── adopters.md ├── api-reference.md ├── api │ └── index.html ├── concurrency-primitives.md ├── documentation.md ├── ecosystem.md ├── faq.md ├── getstarted │ ├── example.md │ └── install.md ├── guide.md ├── index.html ├── io.md ├── scodec.md └── timeseries.md └── testdata ├── celsius.txt ├── fahrenheit.txt └── utf8.txt /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Auto-format source on each compilation 2 | 6248d7d6fe183cd9ceb4104af02883446ea35fb4 3 | 7ad702a21e4af95e188cff9a7352ff3bc17beabd 4 | 5 | # Reformats due to AvoidInfix 6 | 3fa9dea7cf0714796ffe0455c271e9f221fd1b77 7 | 8 | # Scalafmt 9 | 025e055291c47f6ea622a35e55c67d589e13cfc6 10 | 11 | # Steward commits 12 | 165231ee9b2e63798f8fc387ff15383eecc2740b 13 | 0d3ef3b9525b00d44225608decfc1017c1cac600 14 | a423d27102f5a99ac7e94423c0c144b49c30c32b 15 | b0c2ea35e50301c71ce148539a9163632130ad51 16 | f5a03308a9e740e75a1e69fe9a09b2e16b498c5e 17 | 56643bbe535409db54357b415c58a0e60ede0939 18 | 19 | # Scala Steward: Reformat with scalafmt 3.7.1 20 | e5525d3f0da44052fdcfbe844993260bdc044270 21 | 22 | # Scala Steward: Reformat with scalafmt 3.8.2 23 | a0a37ece16ee55056270b4d9ba5c1505ead8af17 24 | 25 | # Scala Steward: Reformat with scalafmt 3.8.6 26 | 52e52b013db077ecb5b5a8f5b6e6113f912556d8 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | Describe the bug and include the fs2 version(s) in use. A reproduction case, either as a PR that adds a unit test or a link to a [Scastie](http://scastie.scala-lang.org), is much appreciated! 11 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thanks for opening a PR! 2 | 3 | If the CI build fails due to Scalafmt, run `sbt scalafmtAll` and push the changes (generally a good idea to run this prior to opening the PR). 4 | 5 | It's also helpful to run `sbt prePR`, which runs tests, generates docs, and performs various checks. 6 | 7 | Feel free to ask questions on the fs2 and fs2-dev channels on the [Typelevel Discord server](https://discord.gg/9V8FZTVZ9R). 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .idea_modules 3 | target 4 | project/boot 5 | *.swp 6 | *.swo 7 | project.vim 8 | tags 9 | .lib 10 | *~ 11 | *# 12 | z_local.sbt 13 | .DS_Store 14 | .ensime 15 | /.ensime_cache 16 | .tags 17 | .metaserver 18 | test-output 19 | .metals 20 | .bloop 21 | project/metals.sbt 22 | project/project 23 | .vscode 24 | .bsp 25 | node_modules 26 | -------------------------------------------------------------------------------- /.sbtopts: -------------------------------------------------------------------------------- 1 | -J-Xms2g 2 | -J-Xmx4g 3 | -J-XX:MaxMetaspaceSize=512m 4 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = "3.9.4" 2 | 3 | style = default 4 | 5 | runner.dialect = scala213source3 6 | 7 | project.excludeFilters = [ 8 | "scalafix/*" 9 | ] 10 | 11 | fileOverride { 12 | "glob:**/scala-3/**" { 13 | runner.dialect = scala3 14 | rewrite.scala3.convertToNewSyntax = false 15 | } 16 | } 17 | 18 | docstrings.wrap = "no" 19 | 20 | maxColumn = 100 21 | 22 | rewrite.rules = [ 23 | AvoidInfix 24 | RedundantBraces 25 | RedundantParens 26 | Imports 27 | PreferCurlyFors 28 | ] 29 | 30 | rewrite.scala3.convertToNewSyntax = true 31 | runner.dialectOverride.allowAsForImportRename = false 32 | runner.dialectOverride.allowStarWildcardImport = false 33 | runner.dialectOverride.allowPostfixStarVarargSplices = false 34 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | To report a potential security vulnerability, email details to mpilquist@gmail.com. Upon confirmation of the vulnerability, we'll use the [Github coordinated disclosure process](https://docs.github.com/en/code-security/security-advisories/about-coordinated-disclosure-of-security-vulnerabilities) to collaborate and publish an advisory. 6 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/fs2/benchmark/ChunkFlatten.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import org.openjdk.jmh.annotations.{Benchmark, Param, Scope, Setup, State} 25 | 26 | import cats.syntax.all._ 27 | 28 | @State(Scope.Thread) 29 | class ChunkFlatten { 30 | @Param(Array("8", "32", "128")) 31 | var numberChunks: Int = _ 32 | 33 | @Param(Array("1", "2", "10", "50")) 34 | var chunkSize: Int = _ 35 | 36 | case class Obj(dummy: Boolean) 37 | object Obj { 38 | def create: Obj = Obj(true) 39 | } 40 | 41 | var chunkSeq: Seq[Chunk[Obj]] = _ 42 | 43 | @Setup 44 | def setup() = 45 | chunkSeq = Seq.range(0, numberChunks).map(_ => Chunk.from(Seq.fill(chunkSize)(Obj.create))) 46 | 47 | @Benchmark 48 | def flatten(): Unit = { 49 | Chunk.from(chunkSeq).flatten 50 | () 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/fs2/benchmark/ConcurrentBenchmark.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package benchmark 24 | 25 | import cats.effect.IO 26 | import cats.effect.unsafe.implicits.global 27 | import org.openjdk.jmh.annotations.{Benchmark, Param, Scope, State} 28 | 29 | @State(Scope.Thread) 30 | class ConcurrentBenchmark { 31 | 32 | @Param(Array("1", "16", "256")) 33 | var concurrent: Int = _ 34 | 35 | @Benchmark 36 | def parJoin(): Int = { 37 | val each = Stream 38 | .range(0, 1000) 39 | .map(i => Stream.eval(IO.pure(i))) 40 | each.parJoin(concurrent).compile.last.unsafeRunSync().get 41 | } 42 | 43 | @Benchmark 44 | def listParJoinUnbounded(): Int = { 45 | val each = List 46 | .range(0, 1000) 47 | .map(i => Stream.eval(IO.pure(i))) 48 | each.parJoinUnbounded.compile.last.unsafeRunSync().get 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/fs2/benchmark/PullBenchmark.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package benchmark 24 | 25 | import cats.effect.IO 26 | import cats.effect.unsafe.implicits.global 27 | import org.openjdk.jmh.annotations.{Benchmark, Param, Scope, State} 28 | 29 | @State(Scope.Thread) 30 | class PullBenchmark { 31 | @Param(Array("8", "256")) 32 | var n: Int = _ 33 | 34 | @Benchmark 35 | def unconsPull(): Int = { 36 | val s: Stream[Pure, Int] = Stream 37 | .chunk(Chunk.from(0 to 2560)) 38 | .repeatPull { s => 39 | s.unconsN(n).flatMap { 40 | case Some((h, t)) => Pull.output(h).as(Some(t)) 41 | case None => Pull.pure(None) 42 | } 43 | } 44 | s 45 | .covary[IO] 46 | .compile 47 | .last 48 | .unsafeRunSync() 49 | .get 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/fs2/benchmark/RangeFoldBenchmark.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package benchmark 24 | 25 | import org.openjdk.jmh.annotations.{Benchmark, Param, Scope, State} 26 | 27 | @State(Scope.Thread) 28 | class RangeFoldBenchmark { 29 | @Param(Array("1", "4096", "665536", "67108863")) 30 | var n: Int = _ 31 | 32 | @Benchmark 33 | def rangeFold(): Option[Long] = 34 | Stream.range(0, n).fold(0L)(_ + _.toLong).compile.last 35 | } 36 | -------------------------------------------------------------------------------- /build-site.md: -------------------------------------------------------------------------------- 1 | # Build documentation site 2 | 3 | Docs are based on: 4 | 5 | - `docsify`, a _dynamic_, markdown-based generator. 6 | - `mdoc`, type-checked scala/markdown compiler 7 | 8 | The source for the docs is in `site`, the website in `mdoc/target/mdoc`. The currently deployed website is in the `gh-pages` branch. 9 | 10 | You can build the site and preview it locally. 11 | 12 | ## With Nix 13 | 14 | 1. Run `nix-shell --run "sbt 'microsite/mdoc --watch'"`. 15 | 2. Run `nix-shell --run "node_modules/docsify-cli/bin/docsify serve mdoc/target/mdoc"` in a different terminal. 16 | 17 | ## Without Nix 18 | 19 | Install `docsify`: 20 | 21 | ``` 22 | npm i docsify-cli -g 23 | ``` 24 | 25 | then, start `mdoc` in an `sbt` session: 26 | 27 | ``` 28 | sbt microsite/mdoc --watch 29 | ``` 30 | 31 | and docsify in a shell session: 32 | 33 | ``` 34 | docsify serve mdoc/target/mdoc 35 | ``` 36 | 37 | and you'll get an updating preview. 38 | 39 | Note that `mdoc` watches the markdown files, so if you change the code itself it will need a manual recompile. 40 | 41 | `docsify` uses 3 special files: `index.html`, `_coverpage.md`, `_sidebar.md`, the sidebar needs to have a specific format: 42 | 43 | - newlines in between headers 44 | - and no extra modifiers inside links `[good]`, `[**bad**]` (or collapse will not work) 45 | -------------------------------------------------------------------------------- /core/js/src/main/scala/fs2/compression/GunzipResult.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package compression 24 | 25 | /** Gunzip decompression results including file properties and 26 | * decompressed content stream, used as follows: 27 | * stream 28 | * .through(gunzip[IO]()) 29 | * .flatMap { gunzipResult => 30 | * // Access properties here. 31 | * gunzipResult.content 32 | * } 33 | * 34 | * @param content Uncompressed content stream. 35 | * @param modificationTime Modification time of compressed file. 36 | * @param fileName File name. 37 | * @param comment File comment. 38 | */ 39 | case class GunzipResult[F[_]]( 40 | content: Stream[F, Byte], 41 | modificationTime: Option[Nothing] = None, 42 | fileName: Option[Nothing] = None, 43 | comment: Option[Nothing] = None 44 | ) 45 | -------------------------------------------------------------------------------- /core/js/src/test/scala/fs2/TestPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | trait TestPlatform { 25 | def isJVM: Boolean = false 26 | def isNative: Boolean = false 27 | } 28 | -------------------------------------------------------------------------------- /core/js/src/test/scala/fs2/hashing/HashingSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package hashing 24 | 25 | import scodec.bits.ByteVector 26 | 27 | trait HashingSuitePlatform { 28 | def digest(algo: HashAlgorithm, str: String): Hash = { 29 | val hash = JsHash.createHash(Hasher.toAlgorithmString(algo)) 30 | hash.update(ByteVector.view(str.getBytes).toUint8Array) 31 | Hash(Chunk.uint8Array(hash.digest())) 32 | } 33 | 34 | def hmac(algo: HashAlgorithm, key: Chunk[Byte], str: String): Hash = { 35 | val hash = JsHash.createHmac(Hasher.toAlgorithmString(algo), key.toUint8Array) 36 | hash.update(ByteVector.view(str.getBytes).toUint8Array) 37 | Hash(Chunk.uint8Array(hash.digest())) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/jvm-native/src/main/scala/fs2/compression/GunzipResult.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package compression 24 | 25 | import java.time.Instant 26 | 27 | /** Gunzip decompression results including file properties and 28 | * decompressed content stream, used as follows: 29 | * stream 30 | * .through(gunzip[IO]()) 31 | * .flatMap { gunzipResult => 32 | * // Access properties here. 33 | * gunzipResult.content 34 | * } 35 | * 36 | * @param content Uncompressed content stream. 37 | * @param modificationTime Modification time of compressed file. 38 | * @param fileName File name. 39 | * @param comment File comment. 40 | */ 41 | case class GunzipResult[F[_]]( 42 | content: Stream[F, Byte], 43 | modificationTime: Option[Instant] = None, 44 | fileName: Option[String] = None, 45 | comment: Option[String] = None 46 | ) 47 | -------------------------------------------------------------------------------- /core/jvm/src/main/scala/fs2/ChunkRuntimePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | private[fs2] trait ChunkRuntimePlatform[+O] 25 | 26 | private[fs2] trait ChunkCompanionRuntimePlatform 27 | -------------------------------------------------------------------------------- /core/jvm/src/test/scala/fs2/TestPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | trait TestPlatform { 25 | def isJVM: Boolean = true 26 | def isNative: Boolean = false 27 | } 28 | -------------------------------------------------------------------------------- /core/jvm/src/test/scala/fs2/hashing/HashingSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package hashing 24 | 25 | import java.security.MessageDigest 26 | import javax.crypto.Mac 27 | import javax.crypto.spec.SecretKeySpec 28 | 29 | trait HashingSuitePlatform { 30 | def digest(algo: HashAlgorithm, str: String): Hash = 31 | Hash( 32 | Chunk.array(MessageDigest.getInstance(Hasher.toAlgorithmString(algo)).digest(str.getBytes)) 33 | ) 34 | 35 | def hmac(algo: HashAlgorithm, key: Chunk[Byte], str: String): Hash = { 36 | val name = Hasher.toMacAlgorithmString(algo) 37 | val m = Mac.getInstance(name) 38 | m.init(new SecretKeySpec(key.toArray, name)) 39 | Hash(Chunk.array(m.doFinal(str.getBytes))) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/native/src/main/scala/fs2/ChunkRuntimePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import scala.scalanative.libc.string._ 25 | import scala.scalanative.unsafe._ 26 | import scala.scalanative.unsigned._ 27 | 28 | private[fs2] trait ChunkRuntimePlatform[+O] 29 | 30 | private[fs2] trait ChunkCompanionRuntimePlatform { 31 | 32 | def fromBytePtr(ptr: Ptr[Byte], length: Int): Chunk[Byte] = { 33 | val bytes = new Array[Byte](length) 34 | memcpy(bytes.atUnsafe(0), ptr, length.toULong) 35 | Chunk.ArraySlice(bytes, 0, length) 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/native/src/test/scala/fs2/TestPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | trait TestPlatform { 25 | def isJVM: Boolean = false 26 | def isNative: Boolean = true 27 | } 28 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2.12/fs2/PartiallyAppliedFromBlockingIteratorCrossCompat.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import cats.effect.kernel.Sync 25 | 26 | private[fs2] trait PartiallyAppliedFromBlockingIteratorCrossCompat { 27 | @deprecated("bincompat", "3.2.10") 28 | private[fs2] def `apply$extension`[F[_], A]( 29 | dummy: Boolean, 30 | iterator: Iterator[A], 31 | chunkSize: Int, 32 | F: Sync[F] 33 | ): Stream[F, A] = 34 | new Stream.PartiallyAppliedFromIterator(dummy).apply(iterator, chunkSize)(F) 35 | } 36 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2.12/fs2/internal/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import scala.collection.generic.CanBuildFrom 25 | import scala.collection.mutable.{ArrayBuilder, Builder} 26 | import scala.reflect.ClassTag 27 | 28 | package object internal { 29 | private[fs2] type Factory[-A, +C] = CanBuildFrom[Nothing, A, C] 30 | 31 | private[fs2] implicit class FactoryOps[-A, +C](private val factory: Factory[A, C]) { 32 | def newBuilder: Builder[A, C] = factory() 33 | } 34 | 35 | private[fs2] def makeArrayBuilder[A](implicit ct: ClassTag[A]): ArrayBuilder[A] = 36 | ArrayBuilder.make()(ct) 37 | } 38 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2.13+/fs2/PartiallyAppliedFromBlockingIteratorCrossCompat.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | private[fs2] trait PartiallyAppliedFromBlockingIteratorCrossCompat 25 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2.13/internal/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import scala.reflect.ClassTag 25 | import scala.collection.mutable.ArrayBuilder 26 | 27 | package object internal { 28 | private[fs2] type Factory[-A, +C] = scala.collection.Factory[A, C] 29 | 30 | private[fs2] def makeArrayBuilder[A](implicit ct: ClassTag[A]): ArrayBuilder[A] = 31 | ArrayBuilder.make(ct) 32 | } 33 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2/fs2/compat/NotGiven.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.compat 23 | 24 | // Scala 2 port of https://github.com/dotty-staging/dotty/blob/3217bc14a309718a79a4d7a99553664974a8d754/library/src-bootstrapped/scala/util/Not.scala 25 | 26 | final class NotGiven[+A] private () 27 | 28 | private[compat] trait NotGivenLowPriority { 29 | implicit def default[A]: NotGiven[A] = NotGiven.value 30 | } 31 | 32 | object NotGiven extends NotGivenLowPriority { 33 | val value: NotGiven[Nothing] = new NotGiven[Nothing] 34 | implicit def amb1[A](implicit ev: A): NotGiven[A] = ??? 35 | implicit def amb2[A](implicit ev: A): NotGiven[A] = ??? 36 | } 37 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-3/fs2/compat/NotGiven.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.compat 23 | 24 | type NotGiven[+A] = scala.util.NotGiven[A] 25 | val NotGiven = scala.util.NotGiven 26 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-3/internal/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import scala.reflect.ClassTag 25 | import scala.collection.mutable.ArrayBuilder 26 | 27 | package object internal { 28 | private[fs2] type Factory[-A, +C] = scala.collection.Factory[A, C] 29 | 30 | private[fs2] def makeArrayBuilder[A](implicit ct: ClassTag[A]): ArrayBuilder[A] = 31 | ArrayBuilder.make(ct) 32 | } 33 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/Fallible.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | /** Indicates that a stream evaluates no effects but unlike [[Pure]], may raise errors. 25 | * 26 | * Uninhabited. 27 | * 28 | * A `Stream[Fallible,O]` can be safely converted to a `Stream[F,O]` for all `F` via `s.lift[F]`, 29 | * provided an `ApplicativeError[F, Throwable]` is available. 30 | */ 31 | sealed trait Fallible[A] 32 | 33 | object Fallible { 34 | implicit val raiseThrowableInstance: RaiseThrowable[Fallible] = new RaiseThrowable[Fallible] {} 35 | } 36 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/compression/ZLibParams.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.compression 23 | 24 | object ZLibParams { 25 | 26 | sealed abstract class Header(private[compression] val juzDeflaterNoWrap: Boolean) 27 | case object Header { 28 | private[fs2] def apply(juzDeflaterNoWrap: Boolean): ZLibParams.Header = 29 | if (juzDeflaterNoWrap) ZLibParams.Header.GZIP else ZLibParams.Header.ZLIB 30 | 31 | case object ZLIB extends Header(juzDeflaterNoWrap = false) 32 | case object GZIP extends Header(juzDeflaterNoWrap = true) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/concurrent/concurrent.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | /** Provides several concurrency primitives. * */ 25 | package object concurrent 26 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/hashing/Hash.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package hashing 24 | 25 | /** Result of a hash operation. */ 26 | final case class Hash( 27 | bytes: Chunk[Byte] 28 | ) { 29 | 30 | override def equals(other: Any) = other match { 31 | case that: Hash => 32 | // Note: following intentionally performs a constant time comparison 33 | val thatBytes = that.bytes 34 | if (bytes.size != thatBytes.size) false 35 | else { 36 | var result, idx = 0 37 | while (idx < bytes.size) { 38 | result = result | (bytes(idx) ^ thatBytes(idx)) 39 | idx += 1 40 | } 41 | result == 0 42 | } 43 | case _ => false 44 | } 45 | 46 | override def toString = bytes.toByteVector.toHex 47 | } 48 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/hashing/HashVerificationException.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package hashing 24 | 25 | import java.io.IOException 26 | 27 | case class HashVerificationException( 28 | expected: Hash, 29 | actual: Hash 30 | ) extends IOException( 31 | s"Hash did not match, expected: $expected, actual: $actual" 32 | ) 33 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/internal/AcquireAfterScopeClosed.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.internal 23 | 24 | private[fs2] case object AcquireAfterScopeClosed extends Throwable { 25 | override def fillInStackTrace = this 26 | } 27 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/fs2/internal/Lease.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.internal 23 | 24 | /** Represents one or more resources that were leased from a scope, causing their 25 | * lifetimes to be extended until `cancel` is invoked on this lease. 26 | */ 27 | private[fs2] abstract class Lease[F[_]] { 28 | 29 | /** Cancels the lease of all resources tracked by this lease. 30 | * 31 | * This may run finalizers on some of the resources (depending on the state of their owning scopes). 32 | * If one or more finalizers fail, the returned action completes with a `Left(t)`, providing the failure. 33 | */ 34 | def cancel: F[Either[Throwable, Unit]] 35 | } 36 | -------------------------------------------------------------------------------- /core/shared/src/test/scala-2.13/fs2/ArraySeqCollectorSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import scala.collection.immutable.ArraySeq 25 | 26 | class ArraySeqCollectorSuite extends Fs2Suite { 27 | 28 | test("work for a tagged ArraySeq") { 29 | assertEquals(Stream.range(1, 5).compile.to(ArraySeq), ArraySeq.range(1, 5)) 30 | } 31 | 32 | test("work for an untagged ArraySeq") { 33 | assertEquals(Stream.range(1, 5).compile.to(ArraySeq.untagged), ArraySeq.range(1, 5)) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/shared/src/test/scala-2.13/fs2/BitSetCollectorSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import scala.collection.immutable.BitSet 25 | 26 | final class BitSetCollectorSuite extends Fs2Suite { 27 | test("work for Bitset") { 28 | assertEquals( 29 | // Ensure the right return type. 30 | Stream(1, 3, 5).compile.to(BitSet): BitSet, 31 | BitSet(1, 3, 5) 32 | ) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/fs2/CompositeFailureSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import cats.data.NonEmptyList 25 | 26 | import scala.util.control.NoStackTrace 27 | 28 | class CompositeFailureSuite extends Fs2Suite { 29 | test("flatten nested exceptions that's one level deep") { 30 | def err(i: Int) = new RuntimeException(i.toString) with NoStackTrace 31 | val compositeFailure = CompositeFailure( 32 | CompositeFailure(err(1), err(2)), 33 | err(3), 34 | List(CompositeFailure(err(4), err(5))) 35 | ) 36 | assertEquals(compositeFailure.all.map(_.getMessage), NonEmptyList.of("1", "2", "3", "4", "5")) 37 | assert(compositeFailure.all.collect { case cf: CompositeFailure => cf }.isEmpty) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/fs2/Counter.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import cats.effect.Sync 25 | import cats.effect.kernel.Ref 26 | import cats.syntax.all._ 27 | 28 | final class Counter[F[_]](private val ref: Ref[F, Long]) { 29 | def increment: F[Unit] = ref.update(_ + 1) 30 | def decrement: F[Unit] = ref.update(_ - 1) 31 | def get: F[Long] = ref.get 32 | } 33 | 34 | object Counter { 35 | def apply[F[_]: Sync]: F[Counter[F]] = Ref[F].of[Long](0L).map(new Counter(_)) 36 | } 37 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/fs2/Err.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | class Err extends RuntimeException 25 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/fs2/MiscellaneousGenerators.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import org.scalacheck.{Arbitrary, Gen} 25 | import Arbitrary.arbitrary 26 | 27 | trait MiscellaneousGenerators { 28 | val throwableGenerator: Gen[Throwable] = 29 | Gen.const(new Err) 30 | implicit val throwableArbitrary: Arbitrary[Throwable] = 31 | Arbitrary(throwableGenerator) 32 | 33 | def arrayGenerator[A: reflect.ClassTag](genA: Gen[A]): Gen[Array[A]] = 34 | Gen.chooseNum(0, 100).flatMap(n => Gen.listOfN(n, genA)).map(_.toArray) 35 | implicit def arrayArbitrary[A: Arbitrary: reflect.ClassTag]: Arbitrary[Array[A]] = 36 | Arbitrary(arrayGenerator(arbitrary[A])) 37 | 38 | def smallLists[A](genA: Gen[A]): Gen[List[A]] = 39 | Gen.posNum[Int].flatMap(n0 => Gen.listOfN(n0 % 20, genA)) 40 | } 41 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/fs2/StreamConflateSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | 24 | import cats.effect.IO 25 | import cats.effect.testkit.TestControl 26 | 27 | import scala.concurrent.duration._ 28 | 29 | class StreamConflateSuite extends Fs2Suite { 30 | 31 | test("conflateMap") { 32 | TestControl.executeEmbed( 33 | Stream 34 | .iterate(0)(_ + 1) 35 | .covary[IO] 36 | .metered(10.millis) 37 | .conflateMap(100)(List(_)) 38 | .metered(101.millis) 39 | .take(5) 40 | .compile 41 | .toList 42 | .assertEquals( 43 | List(0) :: (1 until 10).toList :: 10.until(40).toList.grouped(10).toList 44 | ) 45 | ) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs = { 3 | typelevel-nix.url = "github:typelevel/typelevel-nix"; 4 | nixpkgs.follows = "typelevel-nix/nixpkgs"; 5 | flake-utils.follows = "typelevel-nix/flake-utils"; 6 | }; 7 | 8 | outputs = { self, nixpkgs, flake-utils, typelevel-nix }: 9 | flake-utils.lib.eachDefaultSystem (system: 10 | let 11 | pkgs = import nixpkgs { 12 | inherit system; 13 | overlays = [ typelevel-nix.overlays.default ]; 14 | }; 15 | in 16 | { 17 | devShell = pkgs.devshell.mkShell { 18 | imports = [ typelevel-nix.typelevelShell ]; 19 | name = "fs2-shell"; 20 | typelevelShell = { 21 | jdk.package = pkgs.jdk17; 22 | nodejs.enable = true; 23 | native.enable = true; 24 | native.libraries = [ pkgs.zlib pkgs.s2n-tls pkgs.openssl ]; 25 | }; 26 | }; 27 | } 28 | ); 29 | } -------------------------------------------------------------------------------- /io/js-jvm/src/main/scala/fs2/io/net/Datagram.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | 26 | import com.comcast.ip4s.{IpAddress, SocketAddress} 27 | 28 | /** A single datagram to send to the specified remote address or received from the specified address. 29 | * 30 | * @param remote remote party to send/receive datagram to/from 31 | * @param bytes data to send/receive 32 | */ 33 | final case class Datagram(remote: SocketAddress[IpAddress], bytes: Chunk[Byte]) 34 | -------------------------------------------------------------------------------- /io/js-native/src/main/scala/fs2/io/net/unixsocket/UnixSocketAddressPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.unixsocket 23 | 24 | import fs2.io.file.Path 25 | 26 | private[unixsocket] trait UnixSocketAddressCompanionPlatform { self: UnixSocketAddress.type => 27 | // Cannot use apply b/c of AnyVal-related erasure 28 | def of(path: Path): UnixSocketAddress = apply(path.toString) 29 | } 30 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/file/PermissionsPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | private[file] trait PermissionsPlatform {} 27 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/file/PosixFileKey.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.file 23 | 24 | private[file] final case class PosixFileKey(dev: Long, ino: Long) extends FileKey 25 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/file/ReadCursorPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | private[file] trait ReadCursorCompanionPlatform 27 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/file/WriteCursorPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | private[file] trait WriteCursorCompanionPlatform 27 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/internal/ThrowableOps.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.internal 23 | 24 | import scala.scalajs.js 25 | 26 | private[fs2] object ThrowableOps { 27 | implicit def toThrowableOps(t: Throwable): ThrowableOps = new ThrowableOps(t) 28 | 29 | private[fs2] final class ThrowableOps(t: Throwable) { 30 | def toJSError: js.Error = js.Error(t.getMessage()) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/internal/facade/os.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.internal.facade 23 | 24 | import scala.scalajs.js 25 | import scala.scalajs.js.annotation.JSImport 26 | 27 | private[io] object os { 28 | 29 | @js.native 30 | @JSImport("os", "tmpdir") 31 | def tmpdir(): String = js.native 32 | 33 | @js.native 34 | @JSImport("os", "homedir") 35 | def homedir(): String = js.native 36 | 37 | @js.native 38 | @JSImport("os", "type") 39 | def `type`(): String = js.native 40 | 41 | @js.native 42 | @JSImport("os", "networkInterfaces") 43 | def networkInterfaces(): js.Dictionary[js.Array[NetworkInterfaceInfo]] = js.native 44 | 45 | @js.native 46 | @JSImport("os", "EOL") 47 | def EOL: String = js.native 48 | 49 | @js.native 50 | trait NetworkInterfaceInfo extends js.Object { 51 | def family: String = js.native 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/internal/facade/process.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.internal.facade 23 | 24 | import scala.scalajs.js 25 | import scala.scalajs.js.annotation.JSImport 26 | 27 | private[io] object process { 28 | 29 | @js.native 30 | @JSImport("process", "stdout") 31 | def stdout: fs2.io.Writable = js.native 32 | 33 | @js.native 34 | @JSImport("process", "stdout") 35 | def stderr: fs2.io.Writable = js.native 36 | 37 | @js.native 38 | @JSImport("process", "stdin") 39 | def stdin: fs2.io.Readable = js.native 40 | 41 | @js.native 42 | @JSImport("process", "cwd") 43 | def cwd(): String = js.native 44 | 45 | @js.native 46 | @JSImport("process", "env") 47 | def env: js.Dictionary[String] = js.native 48 | 49 | } 50 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/net/tls/SSLException.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | package tls 26 | 27 | import scala.scalajs.js 28 | 29 | class SSLException(message: String = null, cause: Throwable = null) 30 | extends IOException(message, cause) 31 | private class JavaScriptSSLException(cause: js.JavaScriptException) 32 | extends SSLException(cause = cause) 33 | object SSLException { 34 | private[io] def unapply(cause: js.JavaScriptException): Option[SSLException] = cause match { 35 | case js.JavaScriptException(error: js.Error) 36 | if error.message.contains("TLS") || error.message.contains( 37 | "SSL" 38 | ) || error.message.toLowerCase.contains("certificate") => 39 | Some(new JavaScriptSSLException(cause)) 40 | case _ => None 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /io/js/src/main/scala/fs2/io/net/tls/SSLSession.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.tls 23 | 24 | import scodec.bits.ByteVector 25 | 26 | final class SSLSession private[tls] (val raw: ByteVector) { 27 | 28 | override def equals(obj: Any): Boolean = obj match { 29 | case that: SSLSession => this.raw == that.raw 30 | case _ => false 31 | } 32 | 33 | override def hashCode: Int = raw.hashCode 34 | 35 | override def toString: String = s"SSLSession($raw)" 36 | 37 | } 38 | -------------------------------------------------------------------------------- /io/js/src/test/scala/fs2/io/net/tcp/SocketSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.tcp 23 | 24 | trait SocketSuitePlatform { 25 | 26 | val setupOptionsPlatform = Nil 27 | val optionsPlatform = Nil 28 | 29 | } 30 | -------------------------------------------------------------------------------- /io/js/src/test/scala/fs2/io/net/udp/UdpSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | package udp 26 | 27 | import fs2.io.internal.facade 28 | 29 | trait UdpSuitePlatform extends Fs2Suite { 30 | 31 | val v4Interfaces = facade.os 32 | .networkInterfaces() 33 | .toMap 34 | .collect { 35 | case (k, v) if v.exists(_.family == "IPv4") => k 36 | } 37 | .toList 38 | 39 | val v4ProtocolFamily = "udp4" 40 | 41 | } 42 | -------------------------------------------------------------------------------- /io/js/src/test/scala/fs2/io/net/unixsockets/UnixSocketsSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io.net.unixsocket 24 | 25 | import cats.effect.IO 26 | 27 | trait UnixSocketsSuitePlatform { self: UnixSocketsSuite => 28 | testProvider("node.js")(UnixSockets.forAsync[IO]) 29 | } 30 | -------------------------------------------------------------------------------- /io/jvm-native/src/main/scala/fs2/io/compressionplatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | 25 | import cats.effect.IO 26 | import cats.effect.kernel.Async 27 | import cats.effect.kernel.Sync 28 | import fs2.compression.Compression 29 | 30 | private[io] trait compressionplatform { 31 | 32 | type ZipException = java.util.zip.ZipException 33 | 34 | implicit def fs2ioCompressionForIO: Compression[IO] = Compression.forSync 35 | 36 | def fs2ioCompressionForSync[F[_]: Sync]: Compression[F] = Compression.forSync 37 | 38 | def fs2ioCompressionForAsync[F[_]: Async]: Compression[F] = Compression.forSync 39 | } 40 | -------------------------------------------------------------------------------- /io/jvm-native/src/main/scala/fs2/io/file/CopyFlag.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.file 23 | 24 | import java.nio.file.{CopyOption, StandardCopyOption} 25 | 26 | final class CopyFlag private (private[file] val option: CopyOption) extends AnyVal 27 | 28 | object CopyFlag extends CopyFlagCompanionApi { 29 | def fromCopyOption(option: CopyOption): CopyFlag = new CopyFlag(option) 30 | 31 | val AtomicMove = fromCopyOption(StandardCopyOption.ATOMIC_MOVE) 32 | val CopyAttributes = fromCopyOption(StandardCopyOption.COPY_ATTRIBUTES) 33 | val ReplaceExisting = fromCopyOption(StandardCopyOption.REPLACE_EXISTING) 34 | } 35 | 36 | private[file] trait CopyFlagsCompanionPlatform { 37 | def fromCopyOptions(options: Iterable[CopyOption]): CopyFlags = 38 | CopyFlags(options.map(CopyFlag.fromCopyOption(_)).toList) 39 | } 40 | -------------------------------------------------------------------------------- /io/jvm-native/src/main/scala/fs2/io/file/PermissionsPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | import java.nio.file.attribute.{FileAttribute, PosixFilePermissions} 27 | 28 | private[file] trait PermissionsPlatform { 29 | def toNioFileAttribute: FileAttribute[?] = (this: @unchecked) match { 30 | case p: PosixPermissions => 31 | PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString(p.toString)) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /io/jvm-native/src/main/scala/fs2/io/file/ReadCursorPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | import java.nio.file.{Files => _, Path => JPath, _} 27 | import cats.effect.kernel.{Async, Resource} 28 | 29 | private[file] trait ReadCursorCompanionPlatform { 30 | @deprecated("Use Files[F].readCursor", "3.0.0") 31 | def fromPath[F[_]: Async]( 32 | path: JPath, 33 | flags: Seq[OpenOption] = Nil 34 | ): Resource[F, ReadCursor[F]] = 35 | Files.forAsync[F].readCursor(path, flags) 36 | } 37 | -------------------------------------------------------------------------------- /io/jvm-native/src/main/scala/fs2/io/file/WriteCursorPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | import cats.effect.kernel.{Async, Resource} 27 | 28 | import java.nio.file.{Files => _, Path => JPath, _} 29 | 30 | private[file] trait WriteCursorCompanionPlatform { 31 | @deprecated("Use Files[F].writeCursorFromFileHandle", "3.0.0") 32 | def fromFileHandle[F[_]: Async]( 33 | file: FileHandle[F], 34 | append: Boolean 35 | ): F[WriteCursor[F]] = 36 | Files.forAsync[F].writeCursorFromFileHandle(file, append) 37 | 38 | @deprecated("Use Files[F].writeCursor", "3.0.0") 39 | def fromPath[F[_]: Async]( 40 | path: JPath, 41 | flags: Seq[OpenOption] = List(StandardOpenOption.CREATE) 42 | ): Resource[F, WriteCursor[F]] = 43 | Files.forAsync[F].writeCursor(path, flags) 44 | 45 | } 46 | -------------------------------------------------------------------------------- /io/jvm-native/src/main/scala/fs2/io/net/net.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io 23 | 24 | /** Provides support for doing network I/O -- TCP, UDP, and TLS. */ 25 | package object net { 26 | type ProtocolException = java.net.ProtocolException 27 | type SocketException = java.net.SocketException 28 | type BindException = java.net.BindException 29 | type ConnectException = java.net.ConnectException 30 | type SocketTimeoutException = java.net.SocketTimeoutException 31 | @deprecated("Use ip4s.UnknownHostException instead", "3.2.0") 32 | type UnknownHostException = com.comcast.ip4s.UnknownHostException 33 | type DatagramSocketOption = SocketOption 34 | val DatagramSocketOption = SocketOption 35 | } 36 | -------------------------------------------------------------------------------- /io/jvm-native/src/test/scala/fs2/io/net/tcp/SocketSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.tcp 23 | 24 | import fs2.io.net.SocketOption 25 | 26 | trait SocketSuitePlatform { 27 | 28 | val setupOptionsPlatform = List(SocketOption.sendBufferSize(10000)) 29 | val optionsPlatform = List( 30 | SocketOption.receiveBufferSize(1024), 31 | SocketOption.reuseAddress(true), 32 | SocketOption.reusePort(true), 33 | SocketOption.sendBufferSize(1024) 34 | ) 35 | 36 | } 37 | -------------------------------------------------------------------------------- /io/jvm/src/main/scala/fs2/io/net/DatagramSocketPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | 26 | import com.comcast.ip4s.IpAddress 27 | 28 | private[net] trait DatagramSocketPlatform[F[_]] { 29 | private[net] trait GroupMembershipPlatform { 30 | 31 | /** Blocks datagrams from the specified source address. */ 32 | def block(source: IpAddress): F[Unit] 33 | 34 | /** Unblocks datagrams from the specified source address. */ 35 | def unblock(source: IpAddress): F[Unit] 36 | } 37 | } 38 | 39 | private[net] trait DatagramSocketCompanionPlatform { 40 | type NetworkInterface = java.net.NetworkInterface 41 | } 42 | -------------------------------------------------------------------------------- /io/jvm/src/main/scala/fs2/io/net/tls/SSLEngineTaskRunner.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | package tls 26 | 27 | import javax.net.ssl.SSLEngine 28 | 29 | import cats.effect.Sync 30 | 31 | private[tls] trait SSLEngineTaskRunner[F[_]] { 32 | def runDelegatedTasks: F[Unit] 33 | } 34 | 35 | private[tls] object SSLEngineTaskRunner { 36 | def apply[F[_]]( 37 | engine: SSLEngine 38 | )(implicit F: Sync[F]): SSLEngineTaskRunner[F] = 39 | new SSLEngineTaskRunner[F] { 40 | def runDelegatedTasks: F[Unit] = 41 | F.blocking { 42 | while ({ 43 | val task = engine.getDelegatedTask 44 | if (task ne null) task.run 45 | task ne null 46 | }) {} 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /io/jvm/src/main/scala/fs2/io/net/tls/tls.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net 23 | 24 | package object tls { 25 | type SSLSession = javax.net.ssl.SSLSession 26 | type SSLException = javax.net.ssl.SSLException 27 | } 28 | -------------------------------------------------------------------------------- /io/jvm/src/main/scala/fs2/io/net/unixsocket/UnixSocketAddressPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.unixsocket 23 | 24 | import java.io.File 25 | import java.nio.file.Path 26 | 27 | private[unixsocket] trait UnixSocketAddressCompanionPlatform { self: UnixSocketAddress.type => 28 | def apply(path: Path): UnixSocketAddress = apply(path.toFile()) 29 | def apply(path: File): UnixSocketAddress = apply(path.getPath()) 30 | } 31 | -------------------------------------------------------------------------------- /io/jvm/src/test/scala/fs2/io/net/tls/TLSSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | package tls 26 | 27 | import cats.effect.IO 28 | 29 | abstract class TLSSuite extends Fs2Suite { 30 | def testTlsContext: IO[TLSContext[IO]] = 31 | Network[IO].tlsContext 32 | .fromKeyStoreResource( 33 | "keystore.jks", 34 | "password".toCharArray, 35 | "password".toCharArray 36 | ) 37 | 38 | val logger = TLSLogger.Disabled 39 | // val logger = TLSLogger.Enabled(msg => IO(println(s"\u001b[33m${msg}\u001b[0m"))) 40 | } 41 | -------------------------------------------------------------------------------- /io/jvm/src/test/scala/fs2/io/net/udp/UdpSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | package udp 26 | 27 | import java.net.{Inet4Address, NetworkInterface, StandardProtocolFamily} 28 | 29 | import CollectionCompat._ 30 | 31 | trait UdpSuitePlatform extends Fs2Suite { 32 | 33 | val v4Interfaces = 34 | NetworkInterface.getNetworkInterfaces.asScala.toList.filter { interface => 35 | interface.getInetAddresses.asScala.exists(_.isInstanceOf[Inet4Address]) 36 | } 37 | 38 | val v4ProtocolFamily = StandardProtocolFamily.INET 39 | 40 | } 41 | -------------------------------------------------------------------------------- /io/jvm/src/test/scala/fs2/io/net/unixsocket/UnixSocketsSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io.net.unixsocket 24 | 25 | import cats.effect.IO 26 | 27 | trait UnixSocketsSuitePlatform { self: UnixSocketsSuite => 28 | if (JdkUnixSockets.supported) testProvider("jdk")(JdkUnixSockets.forAsync[IO]) 29 | if (JnrUnixSockets.supported) testProvider("jnr")(JnrUnixSockets.forAsync[IO]) 30 | } 31 | -------------------------------------------------------------------------------- /io/native/src/main/scala/fs2/io/internal/sysun.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.internal 23 | 24 | import scala.scalanative.posix.sys.socket._ 25 | import scala.scalanative.unsafe._ 26 | 27 | private[io] object sysun { 28 | import Nat._ 29 | type _108 = Digit3[_1, _0, _8] 30 | 31 | type sockaddr_un = CStruct2[ 32 | sa_family_t, 33 | CArray[CChar, _108] 34 | ] 35 | 36 | } 37 | 38 | private[io] object sysunOps { 39 | import sysun._ 40 | 41 | implicit final class sockaddr_unOps(val sockaddr_un: Ptr[sockaddr_un]) extends AnyVal { 42 | def sun_family: sa_family_t = sockaddr_un._1 43 | def sun_family_=(sun_family: sa_family_t): Unit = sockaddr_un._1 = sun_family 44 | def sun_path: CArray[CChar, _108] = sockaddr_un._2 45 | def sun_path_=(sun_path: CArray[CChar, _108]): Unit = sockaddr_un._2 = sun_path 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /io/native/src/main/scala/fs2/io/net/Network.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | 26 | import fs2.io.net.tls.TLSContext 27 | 28 | sealed trait Network[F[_]] extends NetworkPlatform[F] with SocketGroup[F] { 29 | def tlsContext: TLSContext.Builder[F] 30 | } 31 | 32 | object Network extends NetworkCompanionPlatform { 33 | private[fs2] trait UnsealedNetwork[F[_]] extends Network[F] 34 | 35 | def apply[F[_]](implicit F: Network[F]): F.type = F 36 | } 37 | -------------------------------------------------------------------------------- /io/native/src/main/scala/fs2/io/net/tls/CertAuthType.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.tls 23 | 24 | sealed abstract class CertAuthType 25 | object CertAuthType { 26 | object None extends CertAuthType 27 | object Required extends CertAuthType 28 | object Optional extends CertAuthType 29 | } 30 | -------------------------------------------------------------------------------- /io/native/src/main/scala/fs2/io/net/tls/SSLException.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io 23 | package net.tls 24 | 25 | import scala.scalanative.unsafe._ 26 | 27 | class SSLException(message: String = null, cause: Throwable = null) 28 | extends IOException(message, cause) 29 | 30 | private[tls] final class S2nException(error: CInt) 31 | extends SSLException(fromCString(s2n.s2n_strerror(error, c"EN"))) 32 | -------------------------------------------------------------------------------- /io/native/src/main/scala/fs2/io/net/tls/SSLSession.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.tls 23 | 24 | import scodec.bits.ByteVector 25 | 26 | final class SSLSession private[tls] (val raw: ByteVector) { 27 | 28 | override def equals(obj: Any): Boolean = obj match { 29 | case that: SSLSession => this.raw == that.raw 30 | case _ => false 31 | } 32 | 33 | override def hashCode: Int = raw.hashCode 34 | 35 | override def toString: String = s"SSLSession($raw)" 36 | 37 | } 38 | -------------------------------------------------------------------------------- /io/native/src/main/scala/fs2/io/net/unixsocket/UnixSocketsPlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.unixsocket 23 | 24 | import cats.effect.LiftIO 25 | import cats.effect.kernel.Async 26 | 27 | private[unixsocket] trait UnixSocketsCompanionPlatform { 28 | implicit def forLiftIO[F[_]: Async: LiftIO]: UnixSockets[F] = 29 | new FdPollingUnixSockets[F] 30 | } 31 | -------------------------------------------------------------------------------- /io/native/src/test/scala/fs2/io/net/unixsockets/UnixSocketsSuitePlatform.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io.net.unixsocket 24 | 25 | import cats.effect.IO 26 | 27 | trait UnixSocketsSuitePlatform { self: UnixSocketsSuite => 28 | testProvider("native")(UnixSockets.forLiftIO[IO]) 29 | } 30 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/compression.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io 23 | 24 | object compression extends compressionplatform 25 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/file/CopyFlagApi.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.file 23 | 24 | private[file] trait CopyFlagCompanionApi { 25 | val ReplaceExisting: CopyFlag 26 | } 27 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/file/CopyFlags.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.file 23 | 24 | case class CopyFlags(value: List[CopyFlag]) { 25 | def contains(flag: CopyFlag): Boolean = value.contains(flag) 26 | } 27 | 28 | object CopyFlags extends CopyFlagsCompanionPlatform { 29 | val empty: CopyFlags = CopyFlags(Nil) 30 | 31 | def apply(flags: CopyFlag*): CopyFlags = CopyFlags(flags.toList) 32 | } 33 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/file/FileKey.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package file 25 | 26 | import cats.kernel.Hash 27 | import cats.Show 28 | 29 | /** An opaque, unique identifier for a file. 30 | * 31 | * Paths which have the same `FileKey` (via univerals equals), 32 | * as reported by `Files[F].getBasicFileAttributes(path).fileKey`, 33 | * are guaranteed to reference the same file on the file system. 34 | * 35 | * Note: not all operating systems and file systems support file keys, 36 | * hence `BasicFileAttributes#fileKey` returns an `Option[FileKey]`. 37 | */ 38 | trait FileKey 39 | 40 | object FileKey { 41 | implicit val hash: Hash[FileKey] = Hash.fromUniversalHashCode[FileKey] 42 | implicit val show: Show[FileKey] = Show.fromToString[FileKey] 43 | } 44 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/file/PathInfo.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.file 23 | 24 | /** Provides a `Path` and its associated `BasicFileAttributes`. */ 25 | case class PathInfo(path: Path, attributes: BasicFileAttributes) 26 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/net/NetworkLowPriority.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net 23 | 24 | import cats.effect.Async 25 | 26 | private[fs2] trait NetworkLowPriority { this: Network.type => 27 | @deprecated("Add Network constraint or use forAsync", "3.7.0") 28 | implicit def implicitForAsync[F[_]: Async]: Network[F] = forAsync 29 | } 30 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/net/SocketOption.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net 23 | 24 | /** Specifies a socket option on a TCP/UDP socket. 25 | * 26 | * The companion provides methods for creating a socket option from each of the 27 | * JDK `java.net.StandardSocketOptions` as well as the ability to construct arbitrary 28 | * additional options. See the docs on `StandardSocketOptions` for details on each. 29 | */ 30 | sealed trait SocketOption { 31 | type Value 32 | val key: SocketOption.Key[Value] 33 | val value: Value 34 | } 35 | 36 | object SocketOption extends SocketOptionCompanionPlatform { 37 | def apply[A](key0: Key[A], value0: A): SocketOption = new SocketOption { 38 | type Value = A 39 | val key = key0 40 | val value = value0 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/net/tls/TLSLogger.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.tls 23 | 24 | sealed trait TLSLogger[+F[_]] 25 | 26 | object TLSLogger { 27 | case object Disabled extends TLSLogger[Nothing] 28 | case class Enabled[F[_]](log: (=> String) => F[Unit]) extends TLSLogger[F] 29 | } 30 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/net/tls/TLSSocket.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package io 24 | package net 25 | package tls 26 | 27 | /** TCP socket that supports encryption via TLS. 28 | * 29 | * To construct a `TLSSocket`, use the `client` and `server` methods on `TLSContext`. 30 | */ 31 | sealed trait TLSSocket[F[_]] extends Socket[F] with TLSSocketPlatform[F] { 32 | 33 | /** Provides access to the current `SSLSession` for purposes of querying 34 | * session info such as the negotiated cipher suite or the peer certificate. 35 | */ 36 | def session: F[SSLSession] 37 | 38 | /** Provides access to the current application protocol that has been negotiated. 39 | */ 40 | def applicationProtocol: F[String] 41 | 42 | } 43 | 44 | object TLSSocket extends TLSSocketCompanionPlatform { 45 | private[tls] trait UnsealedTLSSocket[F[_]] extends TLSSocket[F] 46 | } 47 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/net/unixsocket/UnixSocketAddress.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.net.unixsocket 23 | 24 | case class UnixSocketAddress(path: String) 25 | 26 | object UnixSocketAddress extends UnixSocketAddressCompanionPlatform 27 | -------------------------------------------------------------------------------- /io/shared/src/main/scala/fs2/io/process/Processes.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.io.process 23 | 24 | import cats.effect.IO 25 | import cats.effect.LiftIO 26 | import cats.effect.kernel.Async 27 | import cats.effect.kernel.Resource 28 | 29 | sealed trait Processes[F[_]] { 30 | 31 | def spawn(process: ProcessBuilder): Resource[F, Process[F]] 32 | 33 | } 34 | 35 | private[fs2] trait UnsealedProcesses[F[_]] extends Processes[F] 36 | 37 | object Processes extends ProcessesCompanionPlatform { 38 | def apply[F[_]: Processes]: Processes[F] = implicitly 39 | 40 | def forIO: Processes[IO] = forLiftIO 41 | 42 | implicit def forLiftIO[F[_]: Async: LiftIO]: Processes[F] = { 43 | val _ = LiftIO[F] 44 | forAsync 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /io/shared/src/test/resources/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDfTCCAmWgAwIBAgIEW6AYvzANBgkqhkiG9w0BAQsFADBuMRAwDgYDVQQGEwdV 3 | bmtub3duMRAwDgYDVQQIEwdVbmtub3duMRAwDgYDVQQHEwdVbmtub3duMRAwDgYD 4 | VQQKEwdVbmtub3duMRIwEAYDVQQLEwlGUzIgVGVzdHMxEDAOBgNVBAMTB1Vua25v 5 | d24wIBcNMTkxMjAyMTMyOTM3WhgPMjExODA2MjYxMzI5MzdaMG4xEDAOBgNVBAYT 6 | B1Vua25vd24xEDAOBgNVBAgTB1Vua25vd24xEDAOBgNVBAcTB1Vua25vd24xEDAO 7 | BgNVBAoTB1Vua25vd24xEjAQBgNVBAsTCUZTMiBUZXN0czEQMA4GA1UEAxMHVW5r 8 | bm93bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN4RczREVYw7GQF4 9 | E/dhwmFiGKi5G+0cGcyPQzv1Say3U6V8Haqpn0/aeVVY30T6/Nttu+0kGKv9uQlY 10 | yeHeyPzqdjkRhSVoDCLahAxWSK8cV/B4r9SyynLxsDIoHAzkE0mGcBfsZ1Hpxe6/ 11 | tLZ9SMZunpuQBMLKlE6sELgeY5Iz4ZptlFADr8SIqxhrnc3GYFWCubu3A7d6h5K1 12 | XMfXn+itYmb/y6TGr/8T5YjipvQuJFPv0WNahErZzOkDM/r4mp1BNKDWawJuyh3/ 13 | 6TudzkJUxK2eQowE6TWOeIB9WioMC0YlGUgylZe2vq9AWJkTjPq3duXZlj+Hqnqq 14 | ZOQvWBcCAwEAAaMhMB8wHQYDVR0OBBYEFMEuQ/pix1rrPmvAh/KqSfxFLKfhMA0G 15 | CSqGSIb3DQEBCwUAA4IBAQDX/Nr2FuVhXPkZRrFFVrzqIbNO3ROnkURXXJSXus5v 16 | nvmQOXWHtE5Uy1f6z1iKCYUs6l+M5+YLmxooTZvaoAC6tjPDskIyPGQGVG4MB03E 17 | ahLSBaRGJEZXIHLU9s6lgK0YoZCnhHdD+TXalxS4Jv6ieZJCKbWpkQomYYPWyTC6 18 | lR5XSEBPhPNRzo0wjla9a6th+Zc3KnTzTsQHg65IU0DIQeAIuxG0v3xh4NOmGi2Z 19 | LX5q0qhf9uk88HUwocILO9TLshlTPAF4puf0vS4MICw46g4YonDz7k5VQmzy0ZAV 20 | c6ew1WF0PfBk/3o4F0plkj5nbem57iOU0znKfI0ZYXoR 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /io/shared/src/test/resources/fs2/io/foo: -------------------------------------------------------------------------------- 1 | bar -------------------------------------------------------------------------------- /io/shared/src/test/resources/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDeEXM0RFWMOxkB 3 | eBP3YcJhYhiouRvtHBnMj0M79Umst1OlfB2qqZ9P2nlVWN9E+vzbbbvtJBir/bkJ 4 | WMnh3sj86nY5EYUlaAwi2oQMVkivHFfweK/Usspy8bAyKBwM5BNJhnAX7GdR6cXu 5 | v7S2fUjGbp6bkATCypROrBC4HmOSM+GabZRQA6/EiKsYa53NxmBVgrm7twO3eoeS 6 | tVzH15/orWJm/8ukxq//E+WI4qb0LiRT79FjWoRK2czpAzP6+JqdQTSg1msCbsod 7 | /+k7nc5CVMStnkKMBOk1jniAfVoqDAtGJRlIMpWXtr6vQFiZE4z6t3bl2ZY/h6p6 8 | qmTkL1gXAgMBAAECggEBAMJ6v8zvZ4hXHVAnDD1jlStaEMR60NU3/fQjJzu0VqB3 9 | MT9FUmnrAUWazRYMrgQoVxgIo0NMkHrXypw/8RXp2VV+NKlICbY3yCEiA/EWA7Ov 10 | ++fymfKJ3jkKJ0fVzrMPb0C+Bx88f0PCmwC7TZVgZUK7EBam6zR426eGk2Hb41He 11 | kcUG0Q68modQO172m3bPqNsa32bsjvAZ813KLSs8xFHhJajTjX5kXG+PmN1fenTx 12 | 8cvzOAET62O4XEXsYqD+iENyvqkRkysfqa9uzWyhLiip6NZXJHPuNKi9usVL+ZNj 13 | glJXFMP0K/TFYqgMBnoJF3Y60NMBlTpTyDu1kP0/nCkCgYEA+g/cxpz+1yPEIs+y 14 | cX4qEp2VJpj4HuJdZKingtApg1aSAlAcNf9UZl7EsGz3vf/x/hX6YtTLF9cbyuIR 15 | P+CYEevWJwiLjTjMbd+Z86oeYr/sLqz4+98W3RGTAcRfLyEeM/fc7MEwTSeyIhpZ 16 | Gi+HbxGJMvbj+8tUh6KFd9lDu8MCgYEA41dpfo2MnyA9f2OrEC2Joll/9Kgz+3l9 17 | jZIRQ4YID3Rawi9xLi9Z6aiIudAGFT9hcFU11akIVz6yXvhRGmE6gQ6bim5ebaJe 18 | 69EHchuBl9Pszi7/UUS4cxksVnNwJjrAHXnoESU0DTWRh3AUkBEsKOd0DkSGOma+ 19 | MEI+JDe2cR0CgYEA9Jgfc4aNHxM0/nf6K1kk/iB1i9OEn3D7uUHe1+2VLYq4Ntr1 20 | PTwK6jc4XPm5Onfn1Ija6WELZr5ZyRFnnfupw53TU0rgdbpg+/gDNnvoTN89vkoj 21 | IPsN+h7+lHPoRsk2Kc8AofQ1ssJpU0JCdYKYDuQwN1GXnus8O4+Uza4OutECgYAr 22 | IeCABDcT0bgZPT2tWhZs2PIv5uHF6mzpuTbRStKoq/i0MvAURSOX80PNjSw6R8Yi 23 | 2+fU27cbZmfNIOuyR5Qj/DOCdiIwRsgfkY8KFTHnLmwVSlFih9k+7R2+YTR77FWa 24 | whBHgHl5sBomSht8oeVw9UjNlC6rUebvnQHROUjB+QKBgQDj1g/t+B5lZ03Pc00h 25 | NQxMqTR6wAp3hPX5Wen44+o0ktGkArRP3Iw3x5764EgUudn2p1NibCrjCnj2avCi 26 | Gkkbl0wWcFZiOsvmBL/0ngxdPA5bfwiKKeIavltWufXXHl1fs0C4UIu9fHWpV6z7 27 | NRVO87Wp3BK13bCGUD0DvAdtpA== 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /io/shared/src/test/resources/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/typelevel/fs2/f463cfd058c1503ac391a0bbc9efab7f75ad5ea2/io/shared/src/test/resources/keystore.jks -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | val sbtTypelevelVersion = "0.7.7" 2 | addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) 3 | addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion) 4 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.18.2") 5 | addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17") 6 | addSbtPlugin("com.armanbilge" % "sbt-scala-native-config-brew-github-actions" % "0.3.0") 7 | addSbtPlugin("io.github.sbt-doctest" % "sbt-doctest" % "0.11.1") 8 | addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7") 9 | 10 | libraryDependencySchemes += "com.lihaoyi" %% "geny" % VersionScheme.Always 11 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/Ip4sCodecs.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | 24 | import scodec.Codec 25 | import scodec.bits._ 26 | import scodec.codecs._ 27 | import com.comcast.ip4s._ 28 | 29 | object Ip4sCodecs { 30 | val ipv4: Codec[Ipv4Address] = 31 | bytes(4).xmapc(b => Ipv4Address.fromBytes(b.toArray).get)(a => ByteVector.view(a.toBytes)) 32 | 33 | val ipv6: Codec[Ipv6Address] = 34 | bytes(16).xmapc(b => Ipv6Address.fromBytes(b.toArray).get)(a => ByteVector.view(a.toBytes)) 35 | 36 | val macAddress: Codec[MacAddress] = 37 | bytes(6).xmapc(b => MacAddress.fromBytes(b.toArray).get)(m => ByteVector.view(m.toBytes)) 38 | 39 | val port: Codec[Port] = uint16.xmapc(p => Port.fromInt(p).get)(_.value) 40 | } 41 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/ethernet/EtherType.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols 25 | package ethernet 26 | 27 | object EtherType { 28 | val IPv4 = 0x0800 29 | val IPv6 = 0x86dd 30 | val VLAN = 0x8100 31 | } 32 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/ip/Checksum.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.ip 25 | 26 | import scodec.bits.BitVector 27 | 28 | object Checksum { 29 | 30 | /** Computes the 16-bit one's complement checksum of the specified bit vector. 31 | * @see [[https://tools.ietf.org/html/rfc1071]] 32 | */ 33 | def checksum(bits: BitVector): BitVector = { 34 | var sum = bits.bytes.grouped(2).foldLeft(0) { (acc, b) => 35 | acc + b.toInt(signed = false) 36 | } 37 | while ((sum >> 16) != 0) 38 | sum = (0xffff & sum) + (sum >> 16) 39 | ~BitVector.fromInt(sum).drop(16) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/ip/IpHeader.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package ip 24 | 25 | import fs2.interop.scodec.StreamDecoder 26 | import fs2.protocols.ethernet.{EthernetFrameHeader, EtherType} 27 | 28 | import com.comcast.ip4s.IpAddress 29 | 30 | sealed trait IpHeader { 31 | def protocol: Int 32 | def sourceIp: IpAddress 33 | def destinationIp: IpAddress 34 | } 35 | 36 | object IpHeader { 37 | def sdecoder(ethernetHeader: EthernetFrameHeader): StreamDecoder[IpHeader] = 38 | ethernetHeader.ethertype match { 39 | case Some(EtherType.IPv4) => StreamDecoder.once(Ipv4Header.codec) 40 | case Some(EtherType.IPv6) => StreamDecoder.once(Ipv6Header.codec) 41 | case _ => StreamDecoder.empty 42 | } 43 | } 44 | 45 | private[ip] trait UnsealedIpHeader extends IpHeader 46 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/ip/tcp/TcpFlags.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols 25 | package ip 26 | package tcp 27 | 28 | import scodec.Codec 29 | import scodec.codecs._ 30 | 31 | case class TcpFlags( 32 | cwr: Boolean, 33 | ecn: Boolean, 34 | urg: Boolean, 35 | ack: Boolean, 36 | psh: Boolean, 37 | rst: Boolean, 38 | syn: Boolean, 39 | fin: Boolean 40 | ) 41 | object TcpFlags { 42 | // format: off 43 | implicit val codec: Codec[TcpFlags] = { 44 | ("cwr" | bool(1)) :: 45 | ("ecn" | bool(1)) :: 46 | ("urg" | bool(1)) :: 47 | ("ack" | bool(1)) :: 48 | ("psh" | bool(1)) :: 49 | ("rst" | bool(1)) :: 50 | ("syn" | bool(1)) :: 51 | ("fin" | bool(1)) 52 | }.as[TcpFlags] 53 | // format: on 54 | } 55 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/ip/udp/DatagramHeader.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols 25 | package ip 26 | package udp 27 | 28 | import scodec.Codec 29 | import scodec.codecs._ 30 | import fs2.interop.scodec._ 31 | import com.comcast.ip4s.Port 32 | 33 | case class DatagramHeader(sourcePort: Port, destinationPort: Port, length: Int, checksum: Int) 34 | 35 | object DatagramHeader { 36 | // format: off 37 | implicit val codec: Codec[DatagramHeader] = { 38 | ("src_port" | Ip4sCodecs.port) :: 39 | ("dst_port" | Ip4sCodecs.port) :: 40 | ("length" | uint16 ) :: 41 | ("checksum" | uint16 ) 42 | }.as[DatagramHeader] 43 | // format: on 44 | 45 | def sdecoder(protocol: Int): StreamDecoder[DatagramHeader] = 46 | if (protocol == 17) StreamDecoder.once(codec) 47 | else StreamDecoder.empty 48 | } 49 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/PesPacketHeaderPrefix.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | 26 | import scodec.Codec 27 | import scodec.codecs._ 28 | 29 | case class PesPacketHeaderPrefix(streamId: Int, length: Int) 30 | 31 | object PesPacketHeaderPrefix { 32 | 33 | implicit val codec: Codec[PesPacketHeaderPrefix] = 34 | fixedSizeBytes( 35 | 3, 36 | ("stream_id" | uint8) :: 37 | ("pes_packet_length" | uint16) 38 | ).as[PesPacketHeaderPrefix] 39 | } 40 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols 25 | 26 | import scodec.Codec 27 | import scodec.bits._ 28 | import scodec.codecs._ 29 | 30 | package object mpeg { 31 | 32 | def reserved(bits: Int): Codec[Unit] = constantLenient(BitVector.high(bits.toLong)) 33 | 34 | val crc32mpeg: BitVector => BitVector = 35 | crc(hex"04c11db7".bits, BitVector.high(32), false, false, BitVector.low(32)) 36 | } 37 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/Clock27MHz.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg.transport 25 | 26 | import scala.concurrent.duration.{FiniteDuration, MICROSECONDS} 27 | 28 | case class Clock27MHz(value: Long) { 29 | def toDuration: FiniteDuration = 30 | FiniteDuration(((1000000d / 27000000) * value).toLong, MICROSECONDS) 31 | 32 | def +(that: Clock27MHz): Clock27MHz = Clock27MHz(value + that.value) 33 | def -(that: Clock27MHz): Clock27MHz = Clock27MHz(value - that.value) 34 | } 35 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/ContinuityCounter.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | package transport 26 | 27 | import scodec.Codec 28 | import scodec.codecs.uint 29 | 30 | case class ContinuityCounter(value: Int) { 31 | require(value >= ContinuityCounter.MinValue && value <= ContinuityCounter.MaxValue) 32 | 33 | def next: ContinuityCounter = ContinuityCounter((value + 1) % 16) 34 | } 35 | 36 | object ContinuityCounter { 37 | val MinValue = 0 38 | val MaxValue = 15 39 | 40 | implicit val codec: Codec[ContinuityCounter] = uint(4).xmap(ContinuityCounter.apply, _.value) 41 | } 42 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/ProgramNumber.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | package transport 26 | 27 | import scodec.Codec 28 | import scodec.codecs.uint16 29 | 30 | case class ProgramNumber(value: Int) { 31 | require(value >= ProgramNumber.MinValue && value <= ProgramNumber.MaxValue) 32 | } 33 | 34 | object ProgramNumber { 35 | val MinValue = 0 36 | val MaxValue = 65535 37 | 38 | implicit val codec: Codec[ProgramNumber] = uint16.xmap(ProgramNumber.apply, _.value) 39 | } 40 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/TransportStreamId.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | package transport 26 | 27 | import scodec.Codec 28 | import scodec.codecs.uint16 29 | 30 | case class TransportStreamId(value: Int) { 31 | require(value >= TransportStreamId.MinValue && value <= TransportStreamId.MaxValue) 32 | } 33 | 34 | object TransportStreamId { 35 | val MinValue = 0 36 | val MaxValue = 65535 37 | 38 | implicit val codec: Codec[TransportStreamId] = uint16.xmap(TransportStreamId.apply, _.value) 39 | } 40 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/psi/GroupingError.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | package transport 26 | package psi 27 | 28 | case class GroupingError(tableId: Int, tableIdExtension: Option[Int], message: String) 29 | extends MpegError 30 | 31 | object GroupingError { 32 | def apply(tableId: Int, tableIdExtension: Int, message: String): GroupingError = 33 | new GroupingError(tableId, Some(tableIdExtension), message) 34 | 35 | def apply(tableId: Int, message: String): GroupingError = 36 | new GroupingError(tableId, None, message) 37 | } 38 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/psi/SectionHeader.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | package transport 26 | package psi 27 | 28 | import scodec.Codec 29 | import scodec.bits.BitVector 30 | import scodec.codecs._ 31 | 32 | case class SectionHeader(tableId: Int, extendedSyntax: Boolean, privateBits: BitVector, length: Int) 33 | 34 | object SectionHeader { 35 | 36 | implicit val codec: Codec[SectionHeader] = { 37 | ("table_id" | uint8) :: 38 | ("section_syntax_indicator" | bool) :: 39 | ("private_bits" | bits(3)) :: 40 | ("length" | uint(12)) 41 | }.as[SectionHeader] 42 | } 43 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/mpeg/transport/psi/Table.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.mpeg 25 | package transport 26 | package psi 27 | 28 | /** Indicates the implementor can be treated as a message delivered in an MPEG transport stream. 29 | * 30 | * This library differentiates tables from sections. Sections are the actual messages delivered 31 | * in the transport stream whereas tables are the result of grouping multiple related sections 32 | * together in to a single logical message. 33 | */ 34 | trait Table { 35 | def tableId: Int 36 | } 37 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcap/Record.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols.pcap 25 | 26 | import scodec.bits.{BitVector, ByteOrdering} 27 | import scodec.Codec 28 | import scodec.codecs._ 29 | 30 | case class Record(header: RecordHeader, data: BitVector) 31 | 32 | object Record { 33 | // format: off 34 | implicit def codec(implicit ordering: ByteOrdering): Codec[Record] = "record" | { 35 | ("record_header" | RecordHeader.codec ).flatPrepend { hdr => 36 | ("record_data" | bits(hdr.includedLength.toInt * 8L) ).tuple 37 | }}.as[Record] 38 | // format: on 39 | } 40 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcap/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2.protocols 25 | 26 | import scodec.bits.ByteOrdering 27 | import scodec.Codec 28 | import scodec.codecs._ 29 | 30 | /** Protocol that describes libpcap files. 31 | * 32 | * @see http://wiki.wireshark.org/Development/LibpcapFileFormat 33 | */ 34 | package object pcap { 35 | 36 | def gint16(implicit ordering: ByteOrdering): Codec[Int] = endiannessDependent(int16, int16L) 37 | def guint16(implicit ordering: ByteOrdering): Codec[Int] = endiannessDependent(uint16, uint16L) 38 | def gint32(implicit ordering: ByteOrdering): Codec[Int] = endiannessDependent(int32, int32L) 39 | def guint32(implicit ordering: ByteOrdering): Codec[Long] = endiannessDependent(uint32, uint32L) 40 | } 41 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/BodyBlock.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package pcapng 24 | 25 | import scodec.bits._ 26 | import scodec.Decoder 27 | 28 | trait BodyBlock 29 | 30 | object BodyBlock { 31 | 32 | def decoder(implicit ord: ByteOrdering): Decoder[BodyBlock] = 33 | Decoder.choiceDecoder( 34 | InterfaceDescriptionBlock.codec, 35 | EnhancedPacketBlock.codec, 36 | NameResolutionBlock.codec, 37 | InterfaceStatisticsBlock.codec, 38 | ProcessInformationBlock.codec, 39 | UnrecognizedBlock.codec 40 | ) 41 | } 42 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/InterfaceStatisticsBlock.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package pcapng 24 | 25 | import scodec.bits._ 26 | import scodec.codecs._ 27 | import scodec.Codec 28 | 29 | case class InterfaceStatisticsBlock(length: Length, bytes: ByteVector) extends BodyBlock 30 | 31 | object InterfaceStatisticsBlock { 32 | 33 | def codec(implicit ord: ByteOrdering): Codec[InterfaceStatisticsBlock] = 34 | "ISB" | BlockCodec.ignored(hexConstant).as[InterfaceStatisticsBlock] 35 | 36 | private def hexConstant(implicit ord: ByteOrdering) = 37 | orderDependent(hex"00000005", hex"05000000") 38 | } 39 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/Length.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package pcapng 24 | 25 | import scodec.bits.{ByteOrdering, ByteVector} 26 | 27 | case class Length(bv: ByteVector) extends AnyVal { 28 | def toLong(implicit ord: ByteOrdering): Long = bv.toLong(signed = false, ord) 29 | } 30 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/NameResolutionBlock.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package pcapng 24 | 25 | import scodec.bits._ 26 | import scodec.codecs._ 27 | import scodec.Codec 28 | 29 | case class NameResolutionBlock(length: Length, bytes: ByteVector) extends BodyBlock 30 | 31 | object NameResolutionBlock { 32 | 33 | def codec(implicit ord: ByteOrdering): Codec[NameResolutionBlock] = 34 | "NRB" | BlockCodec.ignored(hexConstant).as[NameResolutionBlock] 35 | 36 | private def hexConstant(implicit ord: ByteOrdering) = 37 | orderDependent(hex"00000004", hex"04000000") 38 | } 39 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/ProcessInformationBlock.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package pcapng 24 | 25 | import scodec.Codec 26 | import scodec.bits._ 27 | import scodec.codecs._ 28 | 29 | case class ProcessInformationBlock(length: Length, bytes: ByteVector) extends BodyBlock 30 | 31 | object ProcessInformationBlock { 32 | 33 | def codec(implicit ord: ByteOrdering): Codec[ProcessInformationBlock] = 34 | "PIB" | BlockCodec.ignored(hexConstant).as[ProcessInformationBlock] 35 | 36 | private def hexConstant(implicit ord: ByteOrdering) = 37 | orderDependent(hex"80000001", hex"01000080") 38 | } 39 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/SimplePacketBlock.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols.pcapng 23 | 24 | import scodec.Codec 25 | import scodec.bits._ 26 | import scodec.codecs._ 27 | 28 | case class SimplePacketBlock(length: Length, bytes: ByteVector) extends BodyBlock 29 | 30 | object SimplePacketBlock { 31 | 32 | def codec(implicit ord: ByteOrdering): Codec[ProcessInformationBlock] = 33 | "SPB" | BlockCodec.ignored(hexConstant).as[ProcessInformationBlock] 34 | 35 | private def hexConstant(implicit ord: ByteOrdering) = 36 | orderDependent(hex"00000003", hex"03000000") 37 | } 38 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/UnrecognizedBlock.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | package pcapng 24 | 25 | import scodec.Codec 26 | import scodec.bits._ 27 | import scodec.codecs._ 28 | 29 | case class UnrecognizedBlock(blockType: ByteVector, length: Length, bytes: ByteVector) 30 | extends BodyBlock 31 | 32 | object UnrecognizedBlock { 33 | 34 | def codec(implicit ord: ByteOrdering): Codec[UnrecognizedBlock] = 35 | "UB" | BlockCodec.unrecognizedBlockType.as[UnrecognizedBlock] 36 | } 37 | -------------------------------------------------------------------------------- /protocols/shared/src/main/scala/fs2/protocols/pcapng/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2.protocols 23 | 24 | import scodec.bits.{ByteOrdering, ByteVector} 25 | 26 | package object pcapng { 27 | 28 | def orderDependent[T]( 29 | big: ByteVector, 30 | little: ByteVector 31 | )(implicit ord: ByteOrdering): ByteVector = 32 | ord match { 33 | case ByteOrdering.BigEndian => big 34 | case ByteOrdering.LittleEndian => little 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /protocols/shared/src/test/scala/fs2/protocols/PcapNgExample.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | package fs2 23 | package protocols 24 | 25 | import cats.effect.{IO, IOApp} 26 | import cats.syntax.foldable._ 27 | import cats.syntax.option._ 28 | import fs2.io.file.{Files, Path} 29 | import fs2.protocols.pcap.LinkType 30 | import fs2.protocols.pcapng.CaptureFile 31 | 32 | object PcapNgExample extends IOApp.Simple { 33 | 34 | def run: IO[Unit] = 35 | output.compile.toList.flatMap(_.traverse_(IO.println)) 36 | 37 | private def byteStream: Stream[IO, Byte] = 38 | Files[IO].readAll(Path("/path/to/pcapng")) 39 | 40 | private def output = 41 | byteStream.through( 42 | CaptureFile.parse { 43 | case (LinkType.Ethernet, bv) => bv.some 44 | case _ => none 45 | } 46 | ) 47 | } 48 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/AkkaSink.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import akka.stream.scaladsl.Sink 7 | 8 | object AkkaSink { 9 | val s: Sink[Int, Unit] = ??? 10 | } 11 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/Bracket.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import cats.effect.IO 7 | import fs2._ 8 | 9 | object Bracket { 10 | val myResource = Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit) 11 | val myComplexResource = Stream.bracket(IO.pure("resource"))(r => Stream.bracket(IO.pure(r+"2"))(r2 => Stream.emit(r2), _ => IO.unit), _ => IO.unit) 12 | val bracketFor = for { 13 | r1 <- Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit) 14 | r2 <- Stream.bracket(IO.pure("resource2"))(r => Stream.emit(r), _ => IO.unit) 15 | } yield () 16 | 17 | for { 18 | r <- Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit) 19 | } yield r 20 | 21 | println(Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit)) 22 | 23 | (Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit), Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit)) 24 | 25 | def somewhereABracket: Stream[IO, String] = { 26 | println("irrelevant") 27 | val internal = Stream.bracket(IO.pure("internal"))(r => Stream.emit(r), _ => IO.unit) 28 | for { 29 | r <- Stream.bracket(IO.pure("resource"))(r => Stream.bracket(IO.pure(r+"2"))(r2 => Stream.emit(r2), _ => IO.unit), _ => IO.unit) 30 | } yield r 31 | Stream.bracket(IO.pure("resource"))(r => Stream.bracket(IO.pure(r+"2"))(r2 => Stream.emit(r2), _ => IO.unit), _ => IO.unit) 32 | } 33 | 34 | def bracketDef: Stream[IO, String] = Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit) 35 | var bracketVar: Stream[IO, String] = Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit) 36 | 37 | def bracketDefFor: Stream[IO, String] = for { 38 | r <- Stream.bracket(IO.pure("resource"))(r => Stream.emit(r), _ => IO.unit) 39 | } yield r 40 | } 41 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/Chunk.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | import fs2._ 6 | 7 | trait ChunkRules { 8 | def s: Stream[Pure, String] 9 | 10 | val segments = s.segments 11 | val mapSegments = s.mapSegments(s => s) 12 | val scanSegments = s.scanSegments(0){case (s, seg) => seg.mapResult(_ => s)} 13 | val scanSegmentsOpt = s.scanSegmentsOpt(0)(_ => None) 14 | val unconsChunk = s.pull.unconsChunk 15 | val pullOutput = Pull.outputChunk(Chunk(1)) 16 | def aSegment: Segment[Int, Unit] 17 | } 18 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/ConcurrentDataTypes.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import cats.effect._ 7 | import cats.syntax.all._ 8 | import fs2._ 9 | import fs2.async.mutable.{Queue, Semaphore, Signal, Topic} 10 | import fs2.async.{Ref, refOf, _} 11 | 12 | import scala.concurrent.ExecutionContext.Implicits.global 13 | import scala.concurrent.duration._ 14 | 15 | abstract class ConcurrentDataTypes[F[_]: ConcurrentEffect: Timer] { 16 | // Ref 17 | val ref: F[Ref[F, Int]] = Ref(1) 18 | refOf[F, Int](1) 19 | refOf(1) 20 | ref.map(_.setSync(1)) 21 | ref.map(_.setAsync(1))/* assert: v1.Removed 22 | ^^^^^^^^ 23 | This got removed. Consider revisiting the implementation */ 24 | val a = ref.flatMap(_.modify(_ + 1)) 25 | val b = ref.flatMap(_.modify2(i => (i, "a"))) 26 | val c = ref.flatMap(_.tryModify(_ + 1)) 27 | val d = ref.flatMap(_.tryModify2(i => (i, "a"))) 28 | 29 | // Deferred 30 | val e: F[Promise[F, Int]] = Promise.empty[F, Int] 31 | val e2: F[Promise[F, Int]] = Promise.empty 32 | val f: F[Promise[F, Int]] = promise[F, Int] 33 | val f2: F[Promise[F, Int]] = promise 34 | e.map(_.cancellableGet) 35 | def scheduler: Scheduler 36 | e.map(_.timedGet(1.second, scheduler)) 37 | 38 | // Semaphore 39 | val s: F[mutable.Semaphore[F]] = fs2.async.mutable.Semaphore(1) 40 | Semaphore(2) 41 | 42 | // Signal 43 | val sig: fs2.async.immutable.Signal[F, Int] = Signal.constant[F, Int](1) 44 | val sigRef: F[Signal[F, Int]] = Signal(1) 45 | 46 | // Queue 47 | val q: F[Queue[F, Int]] = Queue.unbounded 48 | 49 | // Topic 50 | val t: F[Topic[F, Int]] = Topic(1) 51 | } 52 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/Fs2sinkremoval.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import fs2._ 7 | import fs2.{Pipe, Sink, Stream} 8 | import fs2.{Sink => X, Stream} 9 | 10 | object Fs2sinkremoval { 11 | 12 | private def foo[F[_], A](s: Stream[F, A], sink: Sink[F, A]): Stream[F, Unit] = 13 | s.to(sink) 14 | 15 | def bar[F[_], A, B](): Sink[F, A] = ??? 16 | 17 | def baz[F[_], A, B](): X[F, A] = ??? 18 | } 19 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/MyAppClass.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import cats.Applicative 7 | import cats.effect.{Effect, IO} 8 | import fs2.{Stream, StreamApp} 9 | 10 | class MyStreamApp[F[_]: Effect] extends StreamApp[F] { 11 | override def stream(args: List[String], 12 | requestShutdown: F[Unit]): fs2.Stream[F, StreamApp.ExitCode] = 13 | Stream 14 | .eval(Applicative[F].pure("hello")) 15 | .flatMap(_ => Stream.eval(Applicative[F].pure(StreamApp.ExitCode.Success))) /* assert: v1.StreamAppExitCode 16 | ^^^^^^^ 17 | You can remove this 18 | */ 19 | } 20 | 21 | object MyApp extends MyStreamApp[IO] 22 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/MyAppObject.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import cats.Applicative 7 | import cats.effect.IO 8 | import fs2.{Stream, StreamApp} 9 | 10 | object MyAppObject extends StreamApp[IO] { 11 | override def stream(args: List[String], 12 | requestShutdown: IO[Unit]): fs2.Stream[IO, StreamApp.ExitCode] = 13 | Stream 14 | .eval(Applicative[IO].pure("hello")) 15 | .flatMap(_ => Stream.eval(Applicative[IO].pure(StreamApp.ExitCode.Success))) /* assert: v1.StreamAppExitCode 16 | ^^^^^^^ 17 | You can remove this 18 | */ 19 | } 20 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/Scheduler.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import cats.effect._ 7 | import fs2._ 8 | 9 | import scala.concurrent.ExecutionContext.Implicits.global 10 | import scala.concurrent.duration._ 11 | 12 | abstract class SchedulerTimer[F[_]: ConcurrentEffect: Timer] { 13 | 14 | val scheduler: Scheduler 15 | val duration = 1.second 16 | scheduler.effect.sleep[F](duration) 17 | scheduler.sleep[F](duration) 18 | scheduler.sleep_[F](duration) 19 | scheduler.awakeEvery[F](duration) 20 | scheduler.retry(Effect[F].unit, duration, _ => duration, 1) 21 | Stream.eval(Effect[F].unit).through(scheduler.debounce(duration)) 22 | scheduler.effect.delayCancellable(Effect[F].unit, duration) 23 | scheduler.delay(Stream.eval(Effect[F].unit), duration) 24 | } 25 | -------------------------------------------------------------------------------- /scalafix/input/src/main/scala/fix/Usability.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = v1 3 | */ 4 | package fix 5 | 6 | import cats.effect.{Concurrent, IO} 7 | import fs2._ 8 | import scala.concurrent.ExecutionContext.Implicits.global 9 | 10 | trait Usability { 11 | implicit def C: Concurrent[IO] 12 | def s: Stream[IO, String] 13 | 14 | val observe1 = s.observe1(_ => IO.unit) 15 | val join = Stream.emit(s).join(1) 16 | val joinUnbounded = Stream.emit(s).joinUnbounded 17 | } 18 | -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/AkkaSink.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import akka.stream.scaladsl.Sink 4 | 5 | object AkkaSink { 6 | val s: Sink[Int, Unit] = ??? 7 | } 8 | -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/Bracket.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import cats.effect.IO 4 | import fs2._ 5 | 6 | object Bracket { 7 | val myResource = Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 8 | val myComplexResource = Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.bracket(IO.pure(r + "2"))(_ => IO.unit).flatMap(r2 => Stream.emit(r2))) 9 | val bracketFor = for { 10 | r1 <- Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 11 | r2 <- Stream.bracket(IO.pure("resource2"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 12 | } yield () 13 | 14 | for { 15 | r <- Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 16 | } yield r 17 | 18 | println(Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r))) 19 | 20 | (Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)), Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r))) 21 | 22 | def somewhereABracket: Stream[IO, String] = { 23 | println("irrelevant") 24 | val internal = Stream.bracket(IO.pure("internal"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 25 | for { 26 | r <- Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.bracket(IO.pure(r + "2"))(_ => IO.unit).flatMap(r2 => Stream.emit(r2))) 27 | } yield r 28 | Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.bracket(IO.pure(r + "2"))(_ => IO.unit).flatMap(r2 => Stream.emit(r2))) 29 | } 30 | 31 | def bracketDef: Stream[IO, String] = Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 32 | var bracketVar: Stream[IO, String] = Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 33 | 34 | def bracketDefFor: Stream[IO, String] = for { 35 | r <- Stream.bracket(IO.pure("resource"))(_ => IO.unit).flatMap(r => Stream.emit(r)) 36 | } yield r 37 | } 38 | -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/Chunk.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | import fs2._ 3 | import fs2.Chunk 4 | 5 | trait ChunkRules { 6 | def s: Stream[Pure, String] 7 | 8 | val segments = s.chunks 9 | val mapSegments = s.mapChunks(s => s) 10 | val scanSegments = s.scanChunks(0){case (s, seg) => seg.mapResult(_ => s)} 11 | val scanSegmentsOpt = s.scanChunksOpt(0)(_ => None) 12 | val unconsChunk = s.pull.uncons 13 | val pullOutput = Pull.output(Chunk(1)) 14 | def aSegment: Chunk[Int] 15 | } 16 | -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/ConcurrentDataTypes.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import cats.effect._ 4 | import cats.syntax.all._ 5 | import fs2._ 6 | 7 | 8 | 9 | import scala.concurrent.ExecutionContext.Implicits.global 10 | import scala.concurrent.duration._ 11 | import cats.effect.concurrent 12 | import cats.effect.concurrent.{ Deferred, Ref, Semaphore } 13 | import cats.effect.syntax.concurrent._ 14 | import fs2.concurrent.{ Signal, SignallingRef } 15 | 16 | abstract class ConcurrentDataTypes[F[_]: ConcurrentEffect: Timer] { 17 | // Ref 18 | val ref: F[Ref[F, Int]] = Ref.of(1) 19 | Ref.of[F, Int](1) 20 | Ref.of(1) 21 | ref.map(_.set(1)) 22 | ref.map(_.setAsync(1)) 23 | val a = ref.flatMap(_.update(_ + 1)) 24 | val b = ref.flatMap(_.modify(i => (i, "a"))) 25 | val c = ref.flatMap(_.tryUpdate(_ + 1)) 26 | val d = ref.flatMap(_.tryModify(i => (i, "a"))) 27 | 28 | // Deferred 29 | val e: F[Deferred[F, Int]] = Deferred[F, Int] 30 | val e2: F[Deferred[F, Int]] = Deferred 31 | val f: F[Deferred[F, Int]] = promise[F, Int] 32 | val f2: F[Deferred[F, Int]] = promise 33 | e.map(_.get) 34 | def scheduler: Timer[F] 35 | e.map(_.get.timeout(1.second)) 36 | 37 | // Semaphore 38 | val s: F[concurrent.Semaphore[F]] = cats.effect.concurrent.Semaphore(1) 39 | Semaphore(2) 40 | 41 | // Signal 42 | val sig: Signal[F, Int] = Signal.constant[F, Int](1) 43 | val sigRef: F[SignallingRef[F, Int]] = SignallingRef(1) 44 | 45 | // Queue 46 | val q: F[fs2.concurrent.Queue[F, Int]] = fs2.concurrent.Queue.unbounded 47 | 48 | // Topic 49 | val t: F[fs2.concurrent.Topic[F, Int]] = fs2.concurrent.Topic(1) 50 | } -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/Fs2sinkremoval.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import fs2._ 4 | import fs2.{Pipe, Stream} 5 | import fs2.{Pipe => X, Stream} 6 | 7 | object Fs2sinkremoval { 8 | 9 | private def foo[F[_], A](s: Stream[F, A], sink: Pipe[F, A, Unit]): Stream[F, Unit] = 10 | s.through(sink) 11 | 12 | def bar[F[_], A, B](): Pipe[F, A, Unit] = ??? 13 | 14 | def baz[F[_], A, B](): X[F, A, Unit] = ??? 15 | } 16 | -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/MyAppClass.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import cats.Applicative 4 | import cats.effect.{Effect, IO} 5 | import fs2.Stream 6 | import cats.effect.{ ExitCode, IOApp } 7 | import cats.syntax.functor._ 8 | 9 | class MyStreamApp[F[_]: Effect] { 10 | override def program(args: List[String] 11 | ): F[ExitCode] = 12 | Stream 13 | .eval(Applicative[F].pure("hello")) 14 | .flatMap(_ => Stream.eval(Applicative[F].pure(StreamApp.ExitCode.Success))).compile.drain.as(ExitCode.Success) 15 | } 16 | 17 | object MyApp extends MyStreamApp[IO] with IOApp { def run(args: List[String]): IO[ExitCode] = program(args) } -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/MyAppObject.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import cats.Applicative 4 | import cats.effect.IO 5 | import fs2.Stream 6 | import cats.effect.{ ExitCode, IOApp } 7 | import cats.syntax.functor._ 8 | 9 | object MyAppObject extends IOApp { 10 | override def run(args: List[String] 11 | ): IO[ExitCode] = 12 | Stream 13 | .eval(Applicative[IO].pure("hello")) 14 | .flatMap(_ => Stream.eval(Applicative[IO].pure(StreamApp.ExitCode.Success))).compile.drain.as(ExitCode.Success) 15 | } -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/Scheduler.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import cats.effect._ 4 | import fs2._ 5 | 6 | import scala.concurrent.ExecutionContext.Implicits.global 7 | import scala.concurrent.duration._ 8 | 9 | abstract class SchedulerTimer[F[_]: ConcurrentEffect: Timer] { 10 | 11 | val scheduler: Timer[F] 12 | val duration = 1.second 13 | scheduler.sleep(duration) 14 | Stream.sleep[F](duration) 15 | Stream.sleep_[F](duration) 16 | Stream.awakeEvery[F](duration) 17 | Stream.retry(Effect[F].unit, duration, _ => duration, 1) 18 | Stream.eval(Effect[F].unit).debounce(duration) 19 | Concurrent[F].race(Effect[F].unit, scheduler.sleep(duration)) 20 | Stream.eval(Effect[F].unit).delayBy(duration) 21 | } -------------------------------------------------------------------------------- /scalafix/output/src/main/scala/fix/Usability.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import cats.effect.{Concurrent, IO} 4 | import fs2._ 5 | import scala.concurrent.ExecutionContext.Implicits.global 6 | 7 | trait Usability { 8 | implicit def C: Concurrent[IO] 9 | def s: Stream[IO, String] 10 | 11 | val observe1 = s.evalTap(_ => IO.unit) 12 | val join = Stream.emit(s).parJoin(1) 13 | val joinUnbounded = Stream.emit(s).parJoinUnbounded 14 | } 15 | 16 | -------------------------------------------------------------------------------- /scalafix/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /scalafix/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.2") 2 | -------------------------------------------------------------------------------- /scalafix/rules/src/main/resources/META-INF/services/scalafix.v1.Rule: -------------------------------------------------------------------------------- 1 | fix.v1 2 | -------------------------------------------------------------------------------- /scalafix/tests/src/test/scala/fix/RuleSuite.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import org.scalatest.funsuite.AnyFunSuiteLike 4 | import scalafix.testkit.AbstractSemanticRuleSuite 5 | 6 | class RuleSuite extends AbstractSemanticRuleSuite with AnyFunSuiteLike { 7 | runAllTests() 8 | } 9 | -------------------------------------------------------------------------------- /scodec/shared/src/main/scala/fs2/interop/scodec/CodecError.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Functional Streams for Scala 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | // Adapted from scodec-protocols, licensed under 3-clause BSD 23 | 24 | package fs2 25 | package interop 26 | package scodec 27 | 28 | import _root_.scodec.Err 29 | 30 | /** Lifts an `scodec.Err` in to an exception. */ 31 | final case class CodecError(err: Err) extends Exception(err.messageWithContext) 32 | -------------------------------------------------------------------------------- /site/CNAME: -------------------------------------------------------------------------------- 1 | fs2.io 2 | -------------------------------------------------------------------------------- /site/_coverpage.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | # FS2 4 | 5 | > Functional, effectful, concurrent streams for Scala 6 | 7 | - I/O (networking, files) computations in constant memory 8 | - Stateful transformations 9 | - Resource safety and effect evaluation 10 | - Built on [Cats Effect](https://typelevel.org/cats-effect/) and powers [http4s](https://http4s.org), [skunk](https://typelevel.org/skunk/), and [doobie](https://tpolecat.github.io/doobie/) 11 | 12 | [Get Started](getstarted/install.md) 13 | -------------------------------------------------------------------------------- /site/_media/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/typelevel/fs2/f463cfd058c1503ac391a0bbc9efab7f75ad5ea2/site/_media/favicon.png -------------------------------------------------------------------------------- /site/_media/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/typelevel/fs2/f463cfd058c1503ac391a0bbc9efab7f75ad5ea2/site/_media/logo.png -------------------------------------------------------------------------------- /site/_media/logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/typelevel/fs2/f463cfd058c1503ac391a0bbc9efab7f75ad5ea2/site/_media/logo_small.png -------------------------------------------------------------------------------- /site/_media/stream-and-pull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/typelevel/fs2/f463cfd058c1503ac391a0bbc9efab7f75ad5ea2/site/_media/stream-and-pull.png -------------------------------------------------------------------------------- /site/_sidebar.md: -------------------------------------------------------------------------------- 1 | - Getting Started 2 | - [Install](getstarted/install.md) 3 | - [Example](getstarted/example.md) 4 | 5 | - [Guide](guide.md) 6 | - [Concurrency Primitives](concurrency-primitives.md) 7 | - [I/O](io.md) 8 | - [Time Series](timeseries.md) 9 | - [Scodec](scodec.md) 10 | - [API Reference](api-reference.md) 11 | - [FAQ](faq.md) 12 | - [Documentation](documentation.md) 13 | - [Adopters](adopters.md) 14 | - [Ecosystem](ecosystem.md) 15 | -------------------------------------------------------------------------------- /site/adopters.md: -------------------------------------------------------------------------------- 1 | # Adopters 2 | 3 | Here's a (non-exhaustive) list of companies that use FS2 in production. Don't see yours? You can [add it in a PR!](https://github.com/functional-streams-for-scala/fs2/edit/main/README.md) 4 | 5 | * [Chatroulette](https://about.chatroulette.com/) 6 | * [Comcast](https://www.xfinity.com/) 7 | * [CompStak](https://www.compstak.com) 8 | * [Delimobil](https://delimobil.ru/) 9 | * [Disney Streaming](https://www.disneyplus.com) 10 | * [Deutsche Bank AG](https://www.db.com/) 11 | * [Formedix](https://www.formedix.com/) 12 | * [HiFi](https://hi.fi/) 13 | * [Hireproof](https://hireproof.io/) 14 | * [Input Objects](https://inputobjects.eu) 15 | * [ITV](https://itv.com/) 16 | * [Jack Henry](https://www.jackhenry.com) 17 | * [Kaluza](https://www.kaluza.com) 18 | * [OVO Energy](https://www.ovoenergy.com) 19 | * [Ocado Technology](https://www.ocadogroup.com/technology/technology-pioneers) 20 | * [On Air Entertainment](https://onairentertainment.com/) 21 | * [Permutive](https://permutive.com/) 22 | * [Spinoco](https://www.spinoco.com/) 23 | * [Teikametrics](https://www.teikametrics.com) 24 | * [IntentHQ](https://www.intenthq.com) 25 | -------------------------------------------------------------------------------- /site/api-reference.md: -------------------------------------------------------------------------------- 1 | # API Reference 2 | 3 | ### FS2 @VERSION@ (Cats Effect 3) 4 | 5 | * [fs2-core, fs2-io, fs2-reactive-streams, fs2-scodec](@API_URL@) 6 | 7 | ### FS2 2.5.11 (Cats Effect 2) 8 | 9 | * [fs2-core][core-api-v2] 10 | * [fs2-io][io-api-v2] 11 | * [fs2-reactive-streams][rx-api-v2] 12 | 13 | [core-api-v2]: https://s01.oss.sonatype.org/service/local/repositories/releases/archive/co/fs2/fs2-core_2.13/2.5.11/fs2-core_2.13-2.5.11-javadoc.jar/!/fs2/index.html 14 | [io-api-v2]: https://s01.oss.sonatype.org/service/local/repositories/releases/archive/co/fs2/fs2-io_2.13/2.5.11/fs2-io_2.13-2.5.11-javadoc.jar/!/fs2/io/index.html 15 | [rx-api-v2]: https://s01.oss.sonatype.org/service/local/repositories/releases/archive/co/fs2/fs2-reactive-streams_2.13/2.5.11/fs2-reactive-streams_2.13-2.5.11-javadoc.jar/!/fs2/interop/reactivestreams/index.html 16 | -------------------------------------------------------------------------------- /site/api/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |