pub struct ProtobufExporter;Expand description
Exporter for Protobuf format.
Implementations§
Source§impl ProtobufExporter
impl ProtobufExporter
Sourcepub fn export(&self, tables: &[Table]) -> Result<ExportResult, ExportError>
pub fn export(&self, tables: &[Table]) -> Result<ExportResult, ExportError>
Export tables to Protobuf format (SDK interface).
§Arguments
tables- Slice of tables to export
§Returns
An ExportResult containing Protobuf .proto file content (proto3 by default).
§Example
use data_modelling_core::export::protobuf::ProtobufExporter;
use data_modelling_core::models::{Table, Column};
let tables = vec![
Table::new("User".to_string(), vec![Column::new("id".to_string(), "INT64".to_string())]),
];
let exporter = ProtobufExporter;
let result = exporter.export(&tables).unwrap();
assert_eq!(result.format, "protobuf");
assert!(result.content.contains("syntax = \"proto3\""));Sourcepub fn export_with_version(
&self,
tables: &[Table],
version: &str,
) -> Result<ExportResult, ExportError>
pub fn export_with_version( &self, tables: &[Table], version: &str, ) -> Result<ExportResult, ExportError>
Sourcepub fn export_table(table: &Table, field_number: &mut u32) -> String
pub fn export_table(table: &Table, field_number: &mut u32) -> String
Export a table to Protobuf message format.
§Arguments
table- The table to exportfield_number- Mutable reference to field number counter (incremented for each field)
§Returns
A Protobuf message definition as a string.
§Example
use data_modelling_core::export::protobuf::ProtobufExporter;
use data_modelling_core::models::{Table, Column};
let table = Table::new(
"User".to_string(),
vec![Column::new("id".to_string(), "INT64".to_string())],
);
let mut field_number = 0u32;
let proto = ProtobufExporter::export_table(&table, &mut field_number);
assert!(proto.contains("message User"));Export a table to Protobuf message format (proto3 by default).
Auto Trait Implementations§
impl Freeze for ProtobufExporter
impl RefUnwindSafe for ProtobufExporter
impl Send for ProtobufExporter
impl Sync for ProtobufExporter
impl Unpin for ProtobufExporter
impl UnwindSafe for ProtobufExporter
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
Mutably borrows from an owned value. Read more