mars-protocol · marsql::ast
Public declarations and documentation for mars-protocol::marsql::ast.
Package: mars-protocol · Workspace version: 0.1.0 · Module: marsql::ast
This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.
marsql::ast::MarsQuery
A fully-parsed MARS-QL query.
Represents the output of the recursive-descent parser operating on a
MARS-QL string. Every clause is optional except the DISCOVER keyword and
entry type.
Examples
# use mars_protocol::marsql::ast::*;
let q = MarsQuery {
entry_type: QueryEntryType::All,
conditions: vec![],
ordering: vec![],
limit: Some(10),
offset: None,
};
assert!(q.conditions.is_empty());#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct MarsQuery {
/// The entry type to discover.
pub entry_type: QueryEntryType,
/// Zero or more filter conditions (implicit AND).
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub conditions: Vec<Condition>,
/// Zero or more ordering directives.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub ordering: Vec<OrderField>,
/// Optional maximum number of results.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>,
/// Optional cursor for keyset pagination.
#[serde(skip_serializing_if = "Option::is_none")]
pub offset: Option<String>
}Source line: 41.
marsql::ast::QueryEntryType
The target entry type in a DISCOVER clause.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(untagged)]
pub enum QueryEntryType {
/// A specific OAS entry type.
Specific(EntryType),
/// Wildcard `*` — matches all entry types.
All,
}Source line: 70.
marsql::ast::Condition
A single filter condition: field op value.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct Condition {
/// The dotted field path being tested.
pub field: FieldPath,
/// The filter operation and its operand(s).
pub op: FilterOp
}Source line: 85.
marsql::ast::FieldPath
A dotted field path such as "royalty_terms.usage_fee".
Stored as a vector of segments: ["royalty_terms", "usage_fee"].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
pub struct FieldPath(pub Vec<String>);Source line: 101.
marsql::ast::FieldPath::as_dotted
Returns the full dotted path as a single string.
pub fn as_dotted(&self) -> String;Source line: 105.
marsql::ast::FieldPath::len
Returns the number of path segments.
pub fn len(&self) -> usize;Source line: 110.
marsql::ast::FieldPath::is_empty
Returns true if the path has no segments.
pub fn is_empty(&self) -> bool;Source line: 115.
marsql::ast::FieldPath::root
Returns the first segment, if any.
pub fn root(&self) -> Option<&str>;Source line: 120.
marsql::ast::FilterOp
A filter operation with its operand(s).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(tag = "op", content = "value", rename_all = "camelCase")]
pub enum FilterOp {
/// `field = value`
Eq(Value),
/// `field != value`
NotEq(Value),
/// `field > value`
Gt(Value),
/// `field >= value`
Gte(Value),
/// `field < value`
Lt(Value),
/// `field <= value`
Lte(Value),
/// `field CONTAINS value` — set/string membership.
Contains(Value),
/// `field CONTAINS_ALL (v1, v2, ...)` — all values present.
ContainsAll(Vec<Value>),
/// `field CONTAINS_ANY (v1, v2, ...)` — at least one value present.
ContainsAny(Vec<Value>),
/// `field IN (v1, v2, ...)` — field matches one of the listed values.
In(Vec<Value>),
}Source line: 133.
marsql::ast::Value
A literal value in a MARS-QL expression.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(untagged)]
pub enum Value {
/// A UTF-8 string value (double-quoted in source).
String(String),
/// A 64-bit integer value.
Integer(i64),
/// A 64-bit floating-point value.
Number(f64),
/// A boolean value (`true` / `false`).
Boolean(bool),
}Source line: 164.
marsql::ast::OrderField
An ordering directive in an ORDER BY clause.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct OrderField {
/// The field to order by.
pub field: FieldPath,
/// Sort direction (ascending or descending).
pub direction: SortDirection
}Source line: 196.
marsql::ast::SortDirection
Sort direction for ORDER BY clauses.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub enum SortDirection {
/// Ascending order (default).
#[default]
Asc,
/// Descending order.
Desc,
}Source line: 211.
marsql::ast::ShardHint
Shard placement hints for query routing.
When the sharding feature is enabled, queries can include hints that
restrict evaluation to specific shards, clusters, or regions.
#[cfg(feature = "sharding")]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(tag = "kind", content = "id", rename_all = "camelCase")]
pub enum ShardHint {
/// Pin query to a specific shard by ID.
Shard(String),
/// Pin query to all shards in a specific cluster.
Cluster(String),
/// Pin query to all shards in a specific region.
Region(String),
}Source line: 231.
marsql::ast::ShardedQuery
Extension to [MarsQuery] that carries shard routing hints.
#[cfg(feature = "sharding")]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct ShardedQuery {
/// The base MARS-QL query.
pub query: MarsQuery,
/// Zero or more shard placement hints (implicit OR — entry matches if it
/// belongs to *any* hinted shard/cluster/region).
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub hints: Vec<ShardHint>
}Source line: 245.
Source provenance
Source: mars-protocol/src/marsql/ast.rs · SHA-256 c24d9944dad001cb1f4d3f99be569803ffed77428a77f41e2e97794c93ef792e. Package overview.