Skip to main content

HostObject

Trait HostObject 

Source
pub trait HostObject: Send + Sync {
    // Required methods
    fn host_eq(&self, other: &dyn HostObject) -> bool;
    fn host_repr(&self) -> String;
    fn host_str(&self) -> String;
    fn host_hash(&self) -> Option<u64>;
    fn host_cmp(&self, other: &dyn HostObject) -> Option<Ordering>;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn host_pprint(&self) -> String { ... }
    fn host_eq_scalar(&self, _other: &Scalar) -> bool { ... }
    fn host_type_name(&self) -> String { ... }
}
Expand description

A host-language value an object cell carries - the Python binding’s objects: compared and printed by the host itself.

Required Methods§

Source

fn host_eq(&self, other: &dyn HostObject) -> bool

self == other in the host language.

Source

fn host_repr(&self) -> String

The host’s repr (datetime.date(2024, 1, 5)).

Source

fn host_str(&self) -> String

The host’s str (2024-01-05), what astype(str) makes of it.

Source

fn host_hash(&self) -> Option<u64>

The host’s hash, None for an unhashable value (a dict).

Source

fn host_cmp(&self, other: &dyn HostObject) -> Option<Ordering>

self ordered against other in the host language (Python’s < / > / ==), None where the host cannot order them (a date against a time, two dicts).

Source

fn as_any(&self) -> &dyn Any

The value itself, for the host that made it to take back.

Provided Methods§

Source

fn host_pprint(&self) -> String

The cell as pandas displays it in a repr (pprint_thing), where that differs from its str: a tuple’s or array’s items unquoted ((a, 1), [1, 2]); by default its str.

Source

fn host_eq_scalar(&self, _other: &Scalar) -> bool

self == other in the host language for a plain value (numpy’s dtype('float64') == 'float64' is True); false unless the host says so.

Source

fn host_type_name(&self) -> String

The value’s type as the host’s own errors name it (datetime.date, dict), for a refusal pandas lets the host raise.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§