All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zio.config.yaml.package.scala Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
package zio.config

import zio._

import java.io.{File, Reader}
import java.nio.file.Path

package object yaml {
  implicit class FromConfigYaml(c: ZConfig.type) {
    def fromPath[A: Tag](path: Path, descriptor: ConfigDescriptor[A]): Layer[ReadError[String], A] =
      YamlConfig.fromFile(path.toFile, descriptor)

    def fromFile[A: Tag](file: File, descriptor: ConfigDescriptor[A]): Layer[ReadError[String], A] =
      YamlConfig.fromFile(file, descriptor)
  }

  implicit class FromConfigSourceYaml(c: ConfigSource.type) {
    def fromYamlFile(file: File): ConfigSource =
      YamlConfigSource.fromYamlFile(file)

    def fromYamlPath(path: Path): ConfigSource =
      YamlConfigSource.fromYamlPath(path)

    def fromYamlReader(
      reader: Reader,
      sourceName: String = "yaml"
    ): ConfigSource =
      YamlConfigSource.fromYamlReader(reader, sourceName)

    def fromYamlString(
      yamlString: String,
      sourceName: String = "yaml"
    ): ConfigSource =
      YamlConfigSource.fromYamlString(yamlString, sourceName)

    def fromYamlRepr[A](repr: A)(
      loadYaml: A => ZIO[Any, ReadError[String], AnyRef],
      sourceName: String = "yaml"
    ): ConfigSource =
      YamlConfigSource.fromYamlRepr(repr)(loadYaml, sourceName)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy