Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tarantool/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::tuple::{AsTuple, Tuple, TupleBuffer};
use crate::tuple_from_box_api;

/// An index is a group of key values and pointers.
#[derive(Debug, Clone)]
pub struct Index {
space_id: u32,
index_id: u32,
Expand Down Expand Up @@ -151,7 +152,8 @@ pub enum IndexSequenceOption {
}

/// Type of index.
#[derive(Copy, Clone, Debug, Serialize)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all="lowercase")]
pub enum IndexType {
Hash,
Tree,
Expand All @@ -160,7 +162,8 @@ pub enum IndexType {
}

/// Type of index part.
#[derive(Copy, Clone, Debug, Serialize)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all="lowercase")]
pub enum IndexFieldType {
Unsigned,
String,
Expand All @@ -176,7 +179,7 @@ pub enum IndexFieldType {
}

/// Index part.
#[derive(Serialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct IndexPart {
pub field_index: u32,
pub field_type: IndexFieldType,
Expand Down
3 changes: 3 additions & 0 deletions tarantool/src/schema/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ fn insert_new_space(
let mut field_format = Map::<String, Value>::new();
field_format.insert("name".to_string(), Value::String(ft.name.clone()));
field_format.insert("type".to_string(), Value::String(ft.field_type.to_string()));
if let Some(is_nullable) = ft.is_nullable {
field_format.insert("is_nullable".to_string(), Value::Bool(is_nullable));
}
space_format.push(Value::Object(field_format));
}
}
Expand Down
13 changes: 9 additions & 4 deletions tarantool/src/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::fmt;
use std::os::raw::c_char;

use num_traits::ToPrimitive;
use serde::{Serialize, Serializer};
use serde::{Serialize, Serializer, Deserialize, Deserializer};
use serde_json::{Map, Value};

use crate::error::{Error, TarantoolError};
Expand Down Expand Up @@ -93,7 +93,8 @@ impl Into<Space> for SystemSpace {
}

/// Type of engine, used by space.
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Deserialize, PartialEq)]
#[serde(rename_all="lowercase")]
pub enum SpaceEngineType {
Memtx,
Vinyl,
Expand Down Expand Up @@ -144,23 +145,26 @@ impl Default for SpaceCreateOptions {
}
}

#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SpaceFieldFormat {
pub name: String,
#[serde(alias = "type")]
pub field_type: SpaceFieldType,
pub is_nullable: Option<bool>,
}

impl SpaceFieldFormat {
pub fn new(name: &str, ft: SpaceFieldType) -> Self {
return SpaceFieldFormat {
name: name.to_string(),
field_type: ft,
is_nullable: None,
};
}
}

#[derive(Copy, Clone, Debug, Serialize)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all="lowercase")]
pub enum SpaceFieldType {
Any,
Unsigned,
Expand Down Expand Up @@ -217,6 +221,7 @@ pub struct Privilege {

impl AsTuple for Privilege {}

#[derive(Debug, Clone)]
pub struct Space {
id: u32,
}
Expand Down