pub struct GenServerOptions { /* private fields */ }Expand description
Options used to configure a GenServer.
Implementations§
Source§impl GenServerOptions
impl GenServerOptions
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Constructs a new instance of GenServerOptions with the default values.
Examples found in repository?
More examples
examples/application.rs (line 63)
61 async fn start(&self) -> Result<Pid, ExitReason> {
62 let pid = Stack::with_entries(vec!["hello", "world"])
63 .start_link(GenServerOptions::new())
64 .await
65 .expect("Failed to start stack!");
66
67 let result = Stack::call(pid, StackMessage::Pop, None)
68 .await
69 .expect("Stack call failed!");
70
71 tracing::info!("{:?}", result);
72
73 Stack::cast(pid, StackMessage::Push(String::from("rust")));
74
75 let result = Stack::call(pid, StackMessage::Pop, None)
76 .await
77 .expect("Stack call failed!");
78
79 tracing::info!("{:?}", result);
80
81 // Otherwise, the application will run forever waiting for Stack to terminate.
82 Stack::stop(pid, ExitReason::Normal, None).await?;
83
84 Ok(pid)
85 }examples/registry.rs (line 67)
58 async fn start(&self) -> Result<Pid, ExitReason> {
59 // Spawn a registry that will take care of registering 'MySpace'.
60 let children = [
61 Registry::new("space-registry")
62 .with_start(|key| {
63 let RegistryKey::String(id) = key else {
64 panic!()
65 };
66
67 MySpace::new(id).start_link(GenServerOptions::new())
68 })
69 .with_shutdown(Shutdown::Infinity)
70 .child_spec(RegistryOptions::new())
71 .id("space-registry"),
72 ChildSpec::new("test-registry")
73 .start(move || async { Ok(Process::spawn(test_registry())) }),
74 ];
75
76 // Restart only the terminated child.
77 Supervisor::with_children(children)
78 .strategy(SupervisionStrategy::OneForOne)
79 .start_link(SupervisorOptions::new())
80 .await
81 }Trait Implementations§
Source§impl Clone for GenServerOptions
impl Clone for GenServerOptions
Source§fn clone(&self) -> GenServerOptions
fn clone(&self) -> GenServerOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GenServerOptions
impl Debug for GenServerOptions
Source§impl Default for GenServerOptions
impl Default for GenServerOptions
Source§fn default() -> GenServerOptions
fn default() -> GenServerOptions
Returns the “default value” for a type. Read more
Source§impl From<RegistryOptions> for GenServerOptions
impl From<RegistryOptions> for GenServerOptions
Source§fn from(value: RegistryOptions) -> Self
fn from(value: RegistryOptions) -> Self
Converts to this type from the input type.
Source§impl From<SupervisorOptions> for GenServerOptions
impl From<SupervisorOptions> for GenServerOptions
Source§fn from(value: SupervisorOptions) -> Self
fn from(value: SupervisorOptions) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for GenServerOptions
impl RefUnwindSafe for GenServerOptions
impl Send for GenServerOptions
impl Sync for GenServerOptions
impl Unpin for GenServerOptions
impl UnwindSafe for GenServerOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more