Cmpnt

class zixy.container.cmpnts.Cmpnt(impl: ImplT, indexer: int | None = None)[source]

Bases: ViewableItem[ImplT], Generic[ImplT, SpecT], StringRepresentable

A component.

A single component that may be an owning instance referencing a single element in a Rust-bound data object, or a view on an element in another collection.

__eq__(other: object) bool[source]

Return whether self and other are equal.

__init__(impl: ImplT, indexer: int | None = None)[source]

Initialize the component.

Parameters:
  • impl – Rust-bound object storing the data.

  • indexer – Position within Rust-bound array at which the viewed component is stored. When indexer is None, the Cmpnt is an owning view on the sole element of impl.

__repr__() str[source]

Return a string representation of self.

aliases(other: Cmpnt[ImplT, SpecT]) bool[source]

Determine whether self is a view of the same component as other.

clear() None[source]

Set the value of the component to zero.

Note

This method operates in-place.

clone() Self[source]

Return a deep copy of self.

abstractmethod classmethod from_str(source: str, *args: Any, **kwargs: Any) Self

Create an instance of cls from a string.

Parameters:
  • source – String to parse.

  • *args – Positional arguments to forward to a subsequent constructor.

  • **kwargs – Keyword arguments to forward to a subsequent constructor.

Returns:

An instance of cls parsed from source.

impl_type: type[ImplT]
into(t: type[OutT]) OutT

Clone self into a new related container of type t.

Parameters:

t – Type of the new container to create.

Returns:

A new instance of t containing the same data as self.

is_owning() bool

Check if self is owning (i.e. not a view).

classmethod parse(source: str) Self

Parse a string into an instance of cls.

Deprecated:

use from_str() instead.

Parameters:

source – String to parse.

Returns:

An instance of cls parsed from source.

abstractmethod set(source: SpecT | Self) None[source]

Set the value of the component.

Parameters:

source – Specification for the new value.

Note

This method operates in-place.

to_str() str

Return the canonical string representation of self.