Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Conversation

@Boscop
Copy link
Member

@Boscop Boscop commented Feb 15, 2021

fixes #153 by implementing Plugin::new for PluginInstance by using unreachable!().
It's safe because it's never called anyway.
(Plugin::new is only called on the client side and PluginInstance is only used on the host side):
https://github.com/Boscop/rust-vst/blob/0da6e719a26ba67d8302caf26eda1539ee221e81/src/host.rs#L570

Copy link
Contributor

@askeksa askeksa left a comment

Choose a reason for hiding this comment

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

Thanks a lot for doing this! This is a good improvement to the API.

}
}
}
impl Plugin for LadderFilter {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an empty line here.

/// # use vst::event::{Event, MidiEvent};
/// # struct ExamplePlugin { host: HostCallback, send_buf: SendEventBuffer }
/// # impl Plugin for ExamplePlugin {
/// # fn new(host: HostCallback) -> Self { Self { host, send_buf: Default::default() } }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why two levels of Self (here and below)?

Copy link
Member Author

Choose a reason for hiding this comment

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

The first Self is just the return type.
The second one is the literal constructor.

`src/lib.rs`

```rust
#[macro_use]
Copy link
Contributor

Choose a reason for hiding this comment

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

Also fix the comment above to not mention Default.

/// // ...
/// # extern crate vst;
/// # #[macro_use] extern crate log;
/// # use vst::plugin::{Plugin, Info};
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the Plugin trait comment

/// All methods except `get_info` provide a default implementation which does nothing and can be
/// safely overridden.

to say that new is also a required method.

src/plugin.rs Outdated
/// // the host during initialization via Vst::new()
/// // the host during initialization in `Plugin::new()`
/// let host: HostCallback = Default::default();
/// let version = host.vst_version();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest removing most of this example, since implementing Default for a Plugin is no longer needed and also not the recommended way of doing things.

Until we remove the Default implementation for HostCallback (if we decide to do that), the description could say something like

/// All methods in this struct will panic if the `HostCallback` was constructed using
/// `Default::default()` rather than being passed in via `Plugin::new`.

and then just have the two lines here and nothing else as the example.

@Boscop
Copy link
Member Author

Boscop commented Feb 24, 2021

@askeksa Thanks for the review. I applied the suggested changes in the new commit that I just pushed.

@Boscop
Copy link
Member Author

Boscop commented Feb 27, 2021

@askeksa Everything ok now? Can I merge?

@askeksa
Copy link
Contributor

askeksa commented Feb 27, 2021

Yes, looks good.

@Boscop Boscop force-pushed the plugin-instance-new branch from 863496c to 2d9af1a Compare March 7, 2021 07:00
@Boscop Boscop merged commit fd8e173 into RustAudio:master Mar 7, 2021
@Boscop Boscop deleted the plugin-instance-new branch March 7, 2021 07:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't require Plugin to impl Default

2 participants