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

lucuma.schemas.decoders.ExposureTimeModeDecoders.scala Maven / Gradle / Ivy

There is a newer version: 0.107.2
Show newest version
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package lucuma.schemas.decoders

import io.circe.Decoder
import io.circe.generic.semiauto
import io.circe.refined.*
import lucuma.core.model.ExposureTimeMode
import lucuma.odb.json.time.decoder.given

trait ExposureTimeModeDecoders {

  given Decoder[ExposureTimeMode.SignalToNoiseMode] =
    semiauto.deriveDecoder

  given Decoder[ExposureTimeMode.FixedExposureMode] =
    semiauto.deriveDecoder

  given Decoder[ExposureTimeMode] = Decoder.instance { c =>
    c.downField("signalToNoise")
      .as[ExposureTimeMode.SignalToNoiseMode]
      .orElse(c.downField("fixedExposure").as[ExposureTimeMode.FixedExposureMode])
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy