-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create registry options, add Registry::start to start a non-linked re…
…gistry. Allow overriding the name for registry as well, use at your own risk of course.
- Loading branch information
1 parent
2c90ee5
commit 3da0a39
Showing
4 changed files
with
61 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::GenServerOptions; | ||
|
||
/// Options used to configure a Registry. | ||
#[derive(Debug, Default, Clone)] | ||
pub struct RegistryOptions { | ||
pub(crate) name: Option<String>, | ||
} | ||
|
||
impl RegistryOptions { | ||
/// Constructs a new instance of [RegistryOptions] with the default values. | ||
pub const fn new() -> Self { | ||
Self { name: None } | ||
} | ||
|
||
/// Specifies a name to register the Registry under. | ||
pub fn name<T: Into<String>>(mut self, name: T) -> Self { | ||
self.name = Some(name.into()); | ||
self | ||
} | ||
} | ||
|
||
impl From<RegistryOptions> for GenServerOptions { | ||
fn from(mut value: RegistryOptions) -> Self { | ||
let mut options = GenServerOptions::new(); | ||
|
||
if let Some(name) = value.name.take() { | ||
options = options.name(name); | ||
} | ||
|
||
options | ||
} | ||
} |