Skip to main content

ActorBuilder

Struct ActorBuilder 

Source
pub struct ActorBuilder<'a, E: Event, T: Topic<E>, A: Actor<Event = E>> { /* private fields */ }
Expand description

Builder for registering an actor with custom configuration.

Returned by Supervisor::build_actor. Use this when you need to override per-actor settings such as channel capacity or when you want to separate actor construction from topic subscription.

Defaults to no topic subscriptions and channel capacity inherited from the global SupervisorConfig.

§Examples

// Custom channel capacity for a slow consumer
sup.build_actor("writer", |ctx| Writer::new(ctx))
    .topics(&[Topic::Data])
    .channel_capacity(512)
    .build()?;

// Replace the entire actor config
sup.build_actor("fast", |ctx| Fast::new(ctx))
    .topics(Subscribe::all())
    .config(my_config)
    .build()?;

Implementations§

Source§

impl<'a, E: Event, T: Topic<E>, A: Actor<Event = E>> ActorBuilder<'a, E, T, A>

Source

pub fn topics<S>(self, topics: S) -> Self
where S: Into<Subscribe<E, T>>,

Set the topics this actor subscribes to.

Accepts anything that converts to Subscribe: a topic slice, Subscribe::all(), or Subscribe::none().

Source

pub fn config<C>(self, config: C) -> Self
where C: Into<ActorConfig>,

Replace the entire ActorConfig for this actor.

Source

pub fn with_config<F>(self, f: F) -> Self

Transform the current ActorConfig with a closure.

Unlike config() which replaces the entire config, this preserves inherited defaults and lets you tweak individual fields.

sup.build_actor("consumer", |ctx| Consumer::new(ctx))
    .topics(&[Topic::Data])
    .channel_capacity(256)
    .with_config(|c| c.with_max_events_per_tick(64))
    .build()?;
Source

pub fn channel_capacity(self, capacity: usize) -> Self

Set the actor’s mailbox channel capacity.

Shorthand for modifying the channel capacity without replacing the full config. See ActorConfig::with_channel_capacity.

Source

pub fn build(self) -> Result<ActorId>

Register the actor with the supervisor and return its ActorId.

§Errors

Returns Error::DuplicateActorName if an actor with the same name is already registered.

Auto Trait Implementations§

§

impl<'a, E, T, A> Freeze for ActorBuilder<'a, E, T, A>
where A: Freeze,

§

impl<'a, E, T, A> !RefUnwindSafe for ActorBuilder<'a, E, T, A>

§

impl<'a, E, T, A> Send for ActorBuilder<'a, E, T, A>

§

impl<'a, E, T, A> !Sync for ActorBuilder<'a, E, T, A>

§

impl<'a, E, T, A> Unpin for ActorBuilder<'a, E, T, A>
where A: Unpin, T: Unpin,

§

impl<'a, E, T, A> UnsafeUnpin for ActorBuilder<'a, E, T, A>
where A: UnsafeUnpin,

§

impl<'a, E, T, A> !UnwindSafe for ActorBuilder<'a, E, T, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more