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

API Version 2.0 #32

Draft
wants to merge 59 commits into
base: master
Choose a base branch
from

Conversation

ThadHouse
Copy link
Contributor

@ThadHouse ThadHouse commented Sep 2, 2023

This is going to be a 2.0 API.

Its a MUCH better API, does a much better job at expressing rust's memory safety, and has a lot more supported features.

Copy link
Member

@auscompgeek auscompgeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I think using dlopen makes sense given the reasoning provided.

ni-fpga-sys/build.rs Outdated Show resolved Hide resolved

use core::ffi::c_char;
use std::ffi::CString;
impl PartialEq for DlOpenError {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this could be derived instead? Is there a reason it isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enum in the dlopen package isn't PartialEq. Which is why I have to use a newtype at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I'm curious why you need to compare a dlopen::Error in the first place now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since its a possible result in the high level Error enum, that requires it to be PartialEq

ni-fpga-sys/Cargo.toml Outdated Show resolved Hide resolved
}

impl StatusHelper for Status {
fn to_result(self) -> Result<(), Status> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, *-sys crates only handle FFI, with any higher-level abstractions, like turning a status code into a Result, being left to a companion crate. This allows users to use a different abstraction whilst still being able to link to the same system library.

Given we're changing this to dynamically loading the library however, this concern doesn't really exist any more. As such it might make more sense to move all this back into the ni-fpga crate. @connorworley thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move all this code up, and just leave the FFI at the low level.

@connorworley
Copy link
Collaborator

FYI I'm not very involved in FRC lately, so please feel free to take the library in whatever direction you'd like & don't wait on me to review.

@ThadHouse ThadHouse closed this Sep 6, 2023
@ThadHouse ThadHouse reopened this Sep 10, 2023
@ThadHouse
Copy link
Contributor Author

This is going to be a long term PR, but I do want it open.

@ThadHouse ThadHouse marked this pull request as draft September 10, 2023 23:53
@ThadHouse ThadHouse changed the title Switch FPGA API's to be dynamically loaded API Version 2.0 Sep 10, 2023
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

Successfully merging this pull request may close these issues.

3 participants