pub struct WatchContextBuilder { /* private fields */ }
Implementations§
Source§impl WatchContextBuilder
§WatchContextBuilder::build
§Description
The build
method finalizes the construction of a WatchContext
by consuming a
WatchContextBuilder
. It ensures that all necessary components, such as the logger,
are initialized before returning the fully constructed context.
impl WatchContextBuilder
§WatchContextBuilder::build
§Description
The build
method finalizes the construction of a WatchContext
by consuming a
WatchContextBuilder
. It ensures that all necessary components, such as the logger,
are initialized before returning the fully constructed context.
This method is asynchronous because the logger initialization (Logger::new
)
may require I/O operations (e.g., creating or opening log files).
Once called, the builder is consumed and cannot be reused.
§Arguments
This method does not take any additional arguments.
It consumes the builder (self
) that already contains:
branch
: Name of the branch to watch.repo
: The Git repository metadata, including remote and last commit hash.config
: Project configuration associated with this context.project_dir
: Path to the project directory.id
: A unique identifier for the context.paused
: Initial paused state (default:false
).
§Returns
Ok(WatchContext)
– A fully initialized watch context with a ready-to-use logger.Err(anyhow::Error)
– An error occurred during logger creation or path resolution.
§Example
use crate::core::WatchContextBuilder;
let builder = WatchContextBuilder::new(
"main".to_string(),
repo,
config,
"/path/to/project".to_string(),
"project-123".to_string(),
);
let context = builder.build().await?;
println!("WatchContext initialized for branch: {}", context.branch);
§Notes
-
The log file is created in the user’s home directory, under ~/.fleet/logs/
.log. -
If the home directory cannot be resolved or the logger initialization fails, the method returns an error.
-
This method consumes the builder to ensure immutability of the constructed WatchContext.
Auto Trait Implementations§
impl Freeze for WatchContextBuilder
impl RefUnwindSafe for WatchContextBuilder
impl Send for WatchContextBuilder
impl Sync for WatchContextBuilder
impl Unpin for WatchContextBuilder
impl UnwindSafe for WatchContextBuilder
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more