Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the Fields in models::timelines::Source Public #705

Closed
matilda-ray-kerria opened this issue Oct 1, 2024 · 3 comments
Closed

Make the Fields in models::timelines::Source Public #705

matilda-ray-kerria opened this issue Oct 1, 2024 · 3 comments

Comments

@matilda-ray-kerria
Copy link
Contributor

I am currently developing a program to manage GitHub issues and pull requests using the octocrab crate. While trying to extract information about related pull requests from the issue timeline, I noticed that the fields in models::timelines::Source are private.

use octocrab::{
    models::{timelines::Source, Event},
    Octocrab,
};

#[tokio::main]
async fn main() -> octocrab::Result<()> {
    let octocrab = Octocrab::builder()
        .personal_token("GITHUB_PERSONAL_TOKEN".to_string())
        .build()?;

    let page = octocrab
        .issues(OWNER, REPO)
        .list_timeline_events(1u64)
        .per_page(100)
        .send()
        .await?;

    for event in &page {
        if Event::CrossReferenced == event.event {
            if let Some(Source { issue, .. }) = &event.source {
                if issue.pull_request.is_some() {
                    println!(
                        "Found related pull request: #{} - {}",
                        issue.number, issue.title
                    );
                }
            }
        }
    }

    Ok(())
}
error[E0451]: field `issue` of struct `Source` is private
  --> src/main.rs:24:34
   |
24 |             if let Some(Source { issue, .. }) = &event.source {
   |                                  ^^^^^ private field

For more information about this error, try `rustc --explain E0451`.
error: could not compile `octocrab_example` (bin "octocrab_example") due to 1 previous error

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Source {
issue: issues::Issue,
r#type: String,
}

Since Source does not have getter methods defined for its fields, I cannot access these values. Would it be possible to change these fields to public? Alternatively, is there another method to achieve this?

@XAMPPRocky
Copy link
Owner

Thank you for your issue! Seems like an oversight, if you'd like to make a PR making them public I can review it.

@maflcko
Copy link
Contributor

maflcko commented Oct 9, 2024

Can be closed as fixed now?

@matilda-ray-kerria
Copy link
Contributor Author

I'm sorry for forgetting to include the 'closes' keyword in my pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants