vortex_file/write/
postscript.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use flatbuffers::{FlatBufferBuilder, WIPOffset};
use vortex_error::{vortex_bail, VortexResult};
use vortex_flatbuffers::{footer as fb, FlatBufferRoot, WriteFlatBuffer};

#[derive(Debug)]
pub struct Postscript {
    schema_offset: u64,
    layout_offset: u64,
}

impl Postscript {
    pub fn try_new(schema_offset: u64, layout_offset: u64) -> VortexResult<Self> {
        if layout_offset < schema_offset {
            vortex_bail!(
                "layout_offset ({}) must be greater than or equal to schema_offset ({})",
                layout_offset,
                schema_offset
            );
        }
        Ok(Self {
            schema_offset,
            layout_offset,
        })
    }
}

impl FlatBufferRoot for Postscript {}

impl WriteFlatBuffer for Postscript {
    type Target<'a> = fb::Postscript<'a>;

    fn write_flatbuffer<'fb>(
        &self,
        fbb: &mut FlatBufferBuilder<'fb>,
    ) -> WIPOffset<Self::Target<'fb>> {
        fb::Postscript::create(
            fbb,
            &fb::PostscriptArgs {
                schema_offset: self.schema_offset,
                layout_offset: self.layout_offset,
            },
        )
    }
}