pub struct Client { /* private fields */ }Expand description
Ported from Client in client.go.
Holds both a FileSystem (for staging a hermetic test directory
onto disk) and an xianyun_executor::exec::CommandRunner (to
invoke the real kustomize binary), matching the dependency-
injection convention every other backend in this crate already
follows (docker::Client, git::Client, kubectl::Client, …).
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
fsys: Arc<dyn FileSystem>,
executor: Arc<dyn CommandRunner + Send + Sync>,
) -> Self
pub fn new( fsys: Arc<dyn FileSystem>, executor: Arc<dyn CommandRunner + Send + Sync>, ) -> Self
Ported from NewClient. Go’s zero-argument constructor defaults
to the real on-disk filesystem; this port takes the filesystem
and executor explicitly, matching docker/git/kubectl:: Client’s constructor shape.
Sourcepub fn with_fs(
fsys: Arc<dyn FileSystem>,
executor: Arc<dyn CommandRunner + Send + Sync>,
) -> Self
pub fn with_fs( fsys: Arc<dyn FileSystem>, executor: Arc<dyn CommandRunner + Send + Sync>, ) -> Self
Ported from NewClientWithFS. Panics if fsys construction
yields a null pointer – Go’s panic("filesystem cannot be nil")
has no direct Rust analogue since Arc<dyn FileSystem> cannot be
null; callers wanting to exercise the “nil filesystem” case pass
an Option<Arc<dyn FileSystem>> to Client::with_fs_option
instead. See the ported new_client_with_fs_nil_filesystem_panics
test.
Sourcepub fn with_fs_option(
fsys: Option<Arc<dyn FileSystem>>,
executor: Arc<dyn CommandRunner + Send + Sync>,
) -> Self
pub fn with_fs_option( fsys: Option<Arc<dyn FileSystem>>, executor: Arc<dyn CommandRunner + Send + Sync>, ) -> Self
Ported from NewClientWithFS’s nil-check, for the one ported
test that exercises it. Production code should call
Client::with_fs directly with a non-optional Arc.
Sourcepub fn build_cancellable(
&self,
dir: &str,
cancelled: &AtomicBool,
) -> Result<Vec<u8>, KustomizeError>
pub fn build_cancellable( &self, dir: &str, cancelled: &AtomicBool, ) -> Result<Vec<u8>, KustomizeError>
A cancellation-aware variant of Backend::build. Go’s
Client.Build takes a context.Context and can abandon a build
genuinely in flight (a blocked FileSystem.ReadFile call) as
soon as the context is cancelled, without waiting for that call
to return – TestClient_Build_cancellationUnblocksCaller proves
exactly this. Backend::build’s plain synchronous signature has
no way to express that.
Rather than make Backend::build async (a cross-crate
breaking change PORT_NOTES.md already deferred) or add a new
dependency for a cancellation-token type, this runs the real
build on a background thread and polls a channel for its result
while checking cancelled – a plain AtomicBool is enough of
a “cancellation token” here, and both are already in std. If
cancelled flips to true before the background thread
finishes, this returns KustomizeError::Cancelled immediately
and does not wait for (or kill) the background thread, mirroring
Go’s abandoned-goroutine behaviour: the blocked FileSystem call
keeps running until it unblocks on its own, but nothing is left
waiting on it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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