Giter VIP home page Giter VIP logo

Comments (4)

ModProg avatar ModProg commented on June 1, 2024 1

I want to add to this that it makes it really difficult to optionally set some fields.

This is the simplest I could do this, but Maybe there is also a better way, I'm not seeing:

pub struct ChannelInformation<'a> {
    title: Option<&'a str>,
    language: Option<&'a str>,
    game: Option<&'a str>,
}
impl ChannelInformation<'_> {
    fn to_modify_body(&self) -> ModifyChannelInformationBody {
        match (self.title, self.game) {
            (Some(t), Some(g)) => ModifyChannelInformationBody::builder()
                .title(t)
                .game_id(g)
                .broadcaster_language(self.language.map(ToOwned::to_owned))
                .build(),
            (Some(t), None) => ModifyChannelInformationBody::builder()
                .title(t)
                .broadcaster_language(self.language.map(ToOwned::to_owned))
                .build(),
            (None, Some(g)) => ModifyChannelInformationBody::builder()
                .game_id(g)
                .broadcaster_language(self.language.map(ToOwned::to_owned))
                .build(),
            (None, None) => ModifyChannelInformationBody::builder()
                .broadcaster_language(self.language.map(ToOwned::to_owned))
                .build(),
        }
    }
}

from twitch_api.

Emilgardis avatar Emilgardis commented on June 1, 2024 1

this is due to strip_option, should consider not using it at all and just rely on into

from twitch_api.

spikespaz avatar spikespaz commented on June 1, 2024

How does typed_builder currently work? The builder type is private, the build function is crossed-out and RA fills in a single parameter channel_points_custom_reward_redemption_add_v1_builder_error_missing_required_field_broadcaster_user_id. I can't figure out how to finalize the builder.

from twitch_api.

Emilgardis avatar Emilgardis commented on June 1, 2024

@spikespaz the typed_builder crate creates a builder that throws a compile error if setters are missing, the parameter you get contains the missing setter, you need to add broadcaster_user_id. Anyway, I'd recommend using ChannelPointsCustomRewardRedemptionAddV1::broadcaster_user_id(...) instead which is what this issue is about. Looks like I forgot to link the pr that created them: #262

from twitch_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.