fromSession

inline fun <M : Message, B : Message.Builder> fromSession(crossinline newBuilder: () -> B, crossinline f: B.(Session) -> M): Function<Session, M>
fromSession(YourMessage::newBuilder) { session ->
...
build()
}

is mostly equivalent to

{ session ->
YourMessage.newBuilder().apply {
...
}.build()
}