Struct perspective_client::Client
source · pub struct Client { /* private fields */ }Expand description
Implementations§
source§impl Client
impl Client
sourcepub fn new<T>(send_handler: T) -> Self
pub fn new<T>(send_handler: T) -> Self
Create a new client instance with a closure over an external message
queue’s push().
sourcepub fn new_sync<T>(send_handler: T) -> Self
pub fn new_sync<T>(send_handler: T) -> Self
Create a new client instance with a closure over an external message
queue’s push().
pub fn set_send_handler<T>(&mut self, send_handler: T)
sourcepub fn receive(&self, msg: &Vec<u8>) -> Result<(), ClientError>
pub fn receive(&self, msg: &Vec<u8>) -> Result<(), ClientError>
Handle a message from the external message queue.
sourcepub async fn table(
&self,
input: TableData,
options: TableInitOptions
) -> ClientResult<Table>
pub async fn table( &self, input: TableData, options: TableInitOptions ) -> ClientResult<Table>
Creates a new Table from either a schema or data. The [table()] factory
function can be initialized with either a schema, or data in one of these
formats:
- Apache Arrow, as [
pyo3::bytes] (python) or [js_sys::ArrayBuffer] (js) - CSV as a
String - Row-oriented [
pyo3::list] (python) or [js_sys::Array] (js) - Column-oriented [
pyo3::dict] (python) or [js_sys::Object] (js)
When instantiated with data, the schema is inferred from this data. Future
calls to Table::update will coerce to the inferred type this schema.
While this is convenient, inferrence is sometimes imperfect e.g. when
the input is empty, null or ambiguous. For these cases, Client::table can be
instantiated with a explicit schema.
When instantiated with a schema, the resulting Table is empty but with
known column names and column types. When subsqeuently populated with
Table::update, these columns will be coerced to the schema’s type. This
behavior can be useful when Client::table’s column type inferences doesn’t work.
The resulting Table is virtual, and invoking its methods dispatches events
to the client from which it was instantiated (e.g. a Web Worker or WebSocket
client), where the data is stored and all calculation occurs.
§Arguments
- [
arg] - Either schema or initialization data. - [
options] - Optional configuration which provides one of:
§Examples
JavaScript:
const table = await client.table("x,y\n1,2\n3,4");
Python:
table = await async_client.table("x,y\n1,2\n3,4")
Rust:
let table = client.table("x,y\n1,2\n3,4").await;sourcepub async fn open_table(&self, entity_id: String) -> ClientResult<Table>
pub async fn open_table(&self, entity_id: String) -> ClientResult<Table>
Opens a table that is hosted on the server that is connected to the client.
§Examples
[]js const tables = await client.open_table("table_one"); []
[]python tables = await async_client.open_table("table_one"); []
[]rust let tables = client.open_table("table_one").await; []
sourcepub async fn get_hosted_table_names(&self) -> ClientResult<Vec<String>>
pub async fn get_hosted_table_names(&self) -> ClientResult<Vec<String>>
Retrieves the names of all tables that this client has access to.
This can be used in conjunction with Client::open_table.
§Arguments
None.
§Examples
const tables = await client.get_hosted_table_names();
tables = await async_client.get_hosted_table_names();
let tables = client.get_hosted_table_names().await;sourcepub async fn system_info(&self) -> ClientResult<SystemInfo>
pub async fn system_info(&self) -> ClientResult<SystemInfo>
Provides the [SystemInfo] struct.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe 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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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