reifydb-core 0.4.11

Core database interfaces and data structures for ReifyDB
Documentation
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2025 ReifyDB

use std::{
	fmt,
	fmt::{Display, Formatter},
};

use reifydb_type::fragment::Fragment;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum SortDirection {
	Asc,
	Desc,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SortKey {
	pub column: Fragment,
	pub direction: SortDirection,
}

impl Display for SortDirection {
	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
		match self {
			SortDirection::Asc => write!(f, "ASC"),
			SortDirection::Desc => write!(f, "DESC"),
		}
	}
}

impl Display for SortKey {
	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
		write!(f, "{} {}", self.column.fragment(), self.direction)
	}
}