Intro to Tower and the Service Trait - Stefan Baumgartner - Rust Linz, July 2022

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 6

  • @leonie9248
    @leonie9248 2 ปีที่แล้ว +3

    Thanks for sharing this presentation!

  • @marti-nito
    @marti-nito 2 ปีที่แล้ว +4

    I found this intro extremely helpfull, especially the part around 6:35. However I have one question: Wouldn't it make more sense to put the trait bounds of the Logger Service implementation directly on the Logger struct (or at least the Logger impl block)? After all, an e.g. Logger implementation doesn't really make sense, does it? Or is that just not possible with (current) rust?

    • @sbaumg
      @sbaumg 2 ปีที่แล้ว +4

      Yes and no. A Logger won't make sense, that's true, but by moving the trait bounds to the trait impl block you can implement multiple logger implementations for different inner services. The one around 6:35 is for services that deal with hyper Requests, but what if you don't have HTTP and still want to log something, e.g with gRPC or on Lambda? That's a new impl for different trait bounds. That's how you can keep one service but adapt. The best thing: You can be as generic or as specific as you want to be. Defining a trait bound in the struct will limit you in that regard.

    • @cruintention
      @cruintention ปีที่แล้ว

      @sbaumg but if you have a generic trait impl you can't have any others, right?

  • @rumplstiltztinkerstein
    @rumplstiltztinkerstein 2 ปีที่แล้ว

    Very interesting!

  • @Staninna
    @Staninna ปีที่แล้ว

    Thank you, I think I got it down.