Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

I propose a simplification of the TrackLocalWriter trait #747

Open
@Razzwan

Description

The current trait looks like this:

#[async_trait]
pub trait TrackLocalWriter: fmt::Debug {
 async fn write_rtp_with_attributes(
 &self,
 pkt: &rtp::packet::Packet,
 // THIS SECOND PARAM IS NEVER USED!!!
 attr: &Attributes,
 ) -> Result<usize>;
 async fn write_rtp(&self, pkt: &rtp::packet::Packet) -> Result<usize> {
 let attr = Attributes::new();
 self.write_rtp_with_attributes(pkt, &attr).await
 }
 async fn write(&self, mut b: &[u8]) -> Result<usize> {
 let pkt = rtp::packet::Packet::unmarshal(&mut b)?;
 let attr = Attributes::new();
 self.write_rtp_with_attributes(&pkt, &attr).await
 }
}

I suggest simplifying it like this:

#[async_trait]
pub trait TrackLocalWriter: fmt::Debug {
 async fn write_rtp(&self, pkt: &rtp::packet::Packet) -> Result<usize>;
 async fn write(&self, mut b: &[u8]) -> Result<usize> {
 let pkt = rtp::packet::Packet::unmarshal(&mut b)?;
 self.write_rtp(&pkt).await
 }
}

Explanation: I have checked the entire project, and this second parameter, attributes, passes through a large number of entities, but it is never used anywhere. Therefore, if we need to add a second parameter, it is more appropriate to do so when it is used in at least one place. Right now, it's just an unnecessary cognitive load that hinders the understanding of the project. Please note that there is no description of what the parameter should look like. In other words, there is no description (or reference to a description) in the project on how to use this parameter. Similarly, there is no mention of this parameter in the examples. In other words, the parameter exists, but there is no point in its existence.

PS:
In my local version, I removed several hundred references to this parameter, and guess what, not a single test broke!

What do you thing about this suggestion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /