S] extends Encoder[T, S] with Decoder[Option[T], S] object Codec { def encode[T, S](t: T)(implicit enc: Codec[T, S]): S = enc.encode(t) def decode[T, S](s: S)(implicit dec: Codec[T, S]): Option[T] = dec.decode(s) def apply[T, S]()(implicit codec: Codec[T, S]): Codec[T, S] = codec def apply[T, S](encoder: T => S)(decoder: S => Option[T]): Codec[T, S] = new Codec[T, S] { override def encode(t: T): S = encoder(t) override def decode(s: S): Option[T] = decoder(s) } } Codecというシリアライズをサポートする型クラスです