Skip to content

Builder constructor should take arguments #1748

Closed

Description

@yoshuawuyts

I was looking at #1746, and I realized that we've made it so the builder takes its arguments as part of the .build method rather than as part of the constructor. This means we have an API like this:

SandboxBuilder::new().build_from_file(hyperlight_guest_path.clone())?;

Instead in Rust it's more common to have the builder constructor take the arguments, for example like with ContextBuilder::from_waker. Adapted to our builder that would change the API to:

SandboxBuilder::from_file(hyperlight_guest_path.clone()).build()?;

It's not a huge difference, but it is just a little shorter, and at least matches my expectations a bit better. @jprendes what do you think?

Activity

  1. self-assigned this
    on Aug 20, 2026
  2. removed theissue type on Aug 20, 2026
  3. jprendes commented on Aug 20, 2026

    @jprendes
    Contributor

    That sounds good.

    The only caveat is that build_from_bytes takes a &[u8]. With the current approach we don't have to handle ref's lfetimes explicitly. If we have it as an argument we would need to add a lifetime generic to the builder.

  4. jprendes commented on Aug 20, 2026

    @jprendes
    Contributor

    Ok, I can change the internal API to take a Vec<u8> instead of a &[u8] without any penalty (we were converting the &[u8] to a Vec<u8> later on anyway)

  5. self-assigned this
    on Aug 21, 2026
  6. yoshuawuyts commented on Aug 27, 2026

    @yoshuawuyts
    ContributorAuthor

    Closed by #1760.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/APIRelated to the API or public interfacelifecycle/needs-reviewThe issue has not yet been reviewed.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions