Entity

Trait Entity 

Source
pub trait Entity:
    Sized
    + Send
    + Sync
    + 'static {
    type Data: Serialize + DeserializeOwned + Clone + Send + Sync + 'static;

    const NAME: &'static str;

    // Required methods
    fn state_view() -> &'static str;
    fn list_view() -> &'static str;
}
Expand description

Marker trait for HyperStack entities.

This trait is implemented by generated code (via hyperstack sdk create rust) for each entity type defined in a HyperStack spec.

§Example (Generated Code)

pub struct PumpfunTokenEntity;

impl Entity for PumpfunTokenEntity {
    type Data = PumpfunToken;
     
    const NAME: &'static str = "PumpfunToken";
     
    fn state_view() -> &'static str { "PumpfunToken/state" }
    fn list_view() -> &'static str { "PumpfunToken/list" }
}

§Usage

use hyperstack_sdk::HyperStack;
use my_stack::PumpfunTokenEntity;

let hs = HyperStack::connect("wss://example.com").await?;
let token = hs.get::<PumpfunTokenEntity>("mint_address").await;

Required Associated Constants§

Source

const NAME: &'static str

Entity name (e.g., “PumpfunToken”, “SettlementGame”).

This matches the entity name defined in the HyperStack spec.

Required Associated Types§

Source

type Data: Serialize + DeserializeOwned + Clone + Send + Sync + 'static

The data type this entity deserializes to.

This is the struct containing all entity fields (id, info, trading, etc.).

Required Methods§

Source

fn state_view() -> &'static str

View path for single-entity state subscriptions.

Returns a path like “EntityName/state” for subscribing to a single entity’s complete state by key.

Source

fn list_view() -> &'static str

View path for list subscriptions.

Returns a path like “EntityName/list” for subscribing to all entities of this type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§