Skip to main content

Client

Struct Client 

Source
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

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Backend for Client

Source§

fn build(&self, dir: &str) -> Result<Vec<u8>, KustomizeError>

Renders a kustomize directory and returns the resulting YAML bytes.

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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