Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 26 21:07
    scala-steward synchronize #139
  • Jan 26 14:33

    mpilquist on v1.11.0

    (compare)

  • Jan 26 14:32

    mpilquist on 1.11.x

    Setting version to 1.11.0 Updated version to 1.11.1-SNAPS… (compare)

  • Jan 25 10:28
    billpcs starred scodec/scodec
  • Jan 22 22:01
    benhanna starred scodec/scodec
  • Jan 21 20:36
    scala-steward opened #139
  • Jan 21 14:51
    mpilquist closed #130
  • Jan 21 14:48
    mpilquist closed #119
  • Jan 21 14:48
    mpilquist commented #119
  • Jan 21 14:48

    mpilquist on 1.11.x

    Scala 2.13.0-M4 Merge branch 'series/1.10.x' in… Upgraded to latest scala-collec… and 2 more (compare)

  • Jan 21 14:48
    mpilquist closed #138
  • Jan 21 14:40
    mpilquist opened #138
  • Jan 21 14:37

    mpilquist on 1.11.x

    Created 1.11 branch (compare)

  • Jan 21 14:31

    mpilquist on xuwei-k

    Upgraded to 2.13.0-M5 (compare)

  • Jan 21 14:19

    mpilquist on xuwei-k

    Scala 2.13.0-M4 Merge branch 'series/1.10.x' in… Upgraded to latest scala-collec… (compare)

  • Jan 21 14:03

    mpilquist on 1.10.x

    Update sbt-scalajs, scalajs-com… Merge pull request #129 from sc… (compare)

  • Jan 21 14:03
    mpilquist closed #129
  • Jan 21 14:03
    mpilquist closed #126
  • Jan 21 14:03

    mpilquist on 1.10.x

    Pad-left on pbcd codec. Fixes #… Using padLeft in pbcd instead o… Merge pull request #133 from lJ… (compare)

  • Jan 21 14:03
    mpilquist closed #133
Kirill Kushtal
@kushtal

Thanks for answers
Please, can someone explain to me how to create the necessary Transformer to initialize the Codec?
When I check this code, I take the exception: "No implicits arguments of type: Transformer[Int, Route[A]"

class Route[A](value: Int)
object Route {
def codec[A]: Codec[Route[A]] = int32.as[Route[A]]
}

Paul Snively
@paul-snively
What is that code trying to do?
Michael Pilquist
@mpilquist
Change Route to be a case class and it will work — or if you don’t want a case class, use int32.xmapc(new Route(_))(_.value)
But like Paul asked, it would be good to know what you are trying to do to help advise if that’s the right solution
Paul Snively
@paul-snively
I'm mostly thinking A is left abstract there, so I'm not sure what the semantics of Codec[Route[A]] would (be intended to) be.
It may really be true that a Codec[Route[A]] is isomorphic to Codec[Int] for all A, but that seems like it should be more explicit somehow, if so.
Kirill Kushtal
@kushtal
Thanks for answers
int32.xmapc(new Route(_))(_.value)
This code is very suitable for my purposes. But after implementation, I see that I do not need to use this approach. And can solve this problem with a simple Codec[Route]
Thanks again for your responsiveness.
Igal Tabachnik
@hmemcpy
Evening all! I'm trying to (as a toy) to parse the redis protocol using fs2 sockets and scodec. The problem is, I'm not sure how to read the stream, because for some messages I don't have the length specified anywhere. For example, the basic ping/pong message returns a string like this: +PONG\r\n. The protocol states that redis strings are always terminated with \r\n, but I'm not sure how to read "just enough", until I reach there. I may be entirely holding it wrong :)
As reference points, I'm looking at how @tpolecat's skunk reads messages, as well as fs2-chat, but in skunk's case it always reads 5 bytes to detect the length, so it knows how much to read... and in fs2-chat it always reads 1024 bytes, but I'm not sure if it's a good default or just a sample value.
Any hints appreciated!
Christopher Davenport
@ChristopherDavenport
@hmemcpy Take a look at ember in http4s.
Basically a custom pull looking for the seperator.
Igal Tabachnik
@hmemcpy
Awesome! I opened the Parser, looks promising :)
Thank you, I'll look into it some more tomorrow. 2:30 am, time to sleep :)
Paul Snively
@paul-snively
Hi @hmemcpy!
Igal Tabachnik
@hmemcpy
Oh hey Paul! Long time!
Miss you on twitter :)
Paul Snively
@paul-snively
That’s kind of you. Your “I’m sure he doesn’t miss gestures broadly at everything” completely cracked me up.
Ondra Pelech
@sideeffffect
hello, is there a way to compare ByteVectors lexicographically? Is there an Ordering[ByteVector] instance? thanks :pray:
Rob Norris
@tpolecat
@mpilquist do you have a macro to map generically from a ~ b ~ ... to/from an isomorphic case class? I don't want to write it myself ;-)
going via shapeless is a hassle because HList associates the other way.
Michael Pilquist
@mpilquist
No, not without going through Generic
mark lister
@marklister

I am successfully parsing my data up to this point:

val codec={
     ("counter" |  uint16) ~
      ("header"| constant(hex"00 05"))~
      ("length" | length) ~
      ("data type header" | data3) ~
      ("obfuscated message" | obfuscated) // obsfucated is a ByteVector
}

I need to continue parsing obfuscated into smaller chunks? presumably using >>~? Any wisdom?

mark lister
@marklister
And sorry, obsfucated is a Codec[ByteVector]
Igal Tabachnik
@hmemcpy
I have a payload from redis that contains a variable length (can be a byte, can be a long), and it always terminates in \r\n. Is there a way for me using scodec to parse it? E.g. given a BitVector(0x49, 0x49, \r, \n), I want to get 11 as a long...
Igal Tabachnik
@hmemcpy
I'm trying various combinators (e.g. <~) to drop the constant \r\n, but no luck :(
I really want to avoid manually parsing the stream :(
Paul Snively
@paul-snively
There's some very interesting looking, but very difficult-to-wrap-my-head-around, Coproduct support in scodec.
It sounds to me like you need to describe "byte or long or..." as a Coproduct, then parse up to the \r\n into the Coproduct, then determine what it actually is in the usual Coproduct-y ways.
Igal Tabachnik
@hmemcpy
hmm... this might be a good direction to be honest
it's a choice
ok, I'll play with it :D
btw, found this cheatsheet, it's very helpful https://github.com/jrudolph/scodec-cheatsheet/blob/master/README.md
Paul Snively
@paul-snively
Cool!
mark lister
@marklister
@tpolecat is this no good?
scala> case class Foo(i:Int,j:Int)
defined class Foo

scala> (uint8~uint8).decode(hex"0102".bits).require.map(Foo.tupled)
res21: scodec.DecodeResult[Foo] = DecodeResult(Foo(1,2),BitVector(empty))
Rob Norris
@tpolecat
Yeah I need to go the other way so I could do Foo.apply and then x => Foo.unapply(x).get but I don't like that last bit. But it also doesn't work with a ~ b ~ c because the type is ((A, B), C) and not (A, B, C)
mark lister
@marklister
And flattenLeftPairs produces an HList... mmmm
Paul Snively
@paul-snively
Yeah, isn’t flattening a nested tuple a Shapeless example?
Diego E. Alonso Blas
@diesalbla
Good morning.
Has anything built some type-class based library for decoding/encoding data into scodec-byte-vectors? Bit like what circe does with Json
Michael Pilquist
@mpilquist
No cursors per se but Encoder/Decoder/Codec along with opt-in derivation
Dinesh Narayanan
@ndchandar
Hello,
I am a scodec beginner. I need some help on how to possibly implement myPacketCodec1/myPacketCodec2 in this example https://gist.github.com/ndchandar/a3bb3419bcce6b0c1b143db7f37f07be
Basically i am not able to visualize how to encode case classes that are dependent on other product types
Igal Tabachnik
@hmemcpy
Evening folks! I have a reply that supposed to return the number of items to process, but sometimes returns -1
I'm doing something like listOfN(size, BulkReply.decoderNoTag).as[MultiBulkReply], and it works great. How can I handle the case where size decodes -1? I would like to create a MultiBulkReply with an empty list
case class MultiBulkReply(messages: List[BulkReply]) is its definition
Diego E. Alonso Blas
@diesalbla
Good morning.
I am having problems to find a scodec binary for Scala 2.13. Are there any releases planned for this?
Michael Pilquist
@mpilquist
@diesalbla scodec-core 1.11.4 is cross published for 2.11, 2.12, 2.13
I need to update the scodec website with the recent releases, or perhaps just remove that page as it’s always out of date
Diego E. Alonso Blas
@diesalbla
Microsites are not too bad, and are included in the same repo as the source code :)