[][src]Trait gf::support::protobuf::TaggedDataRepr

pub trait TaggedDataRepr: Sized {
    const TAG: &'static str;
    const LATEST_VERSION: NonZeroU32;

    fn from_tagged_data(src: TaggedData) -> Result<Self, ProtobufError>;
fn to_tagged_data_version(
        &self,
        version: NonZeroU32
    ) -> Result<TaggedData, ProtobufError>; fn to_tagged_data(&self) -> TaggedData { ... }
fn from_tagged_data_bytes(bytes: &[u8]) -> Result<Self> { ... }
fn to_tagged_data_bytes(&self) -> Vec<u8> { ... }
fn read_from_tagged_data_file<P: AsRef<Path>>(path: P) -> Result<Self> { ... }
fn write_to_tagged_data_file<P: AsRef<Path>>(&self, path: P) -> Result<()> { ... } }

An object that can be represented as a TaggedData structure.

Associated Constants

const TAG: &'static str

Supported tag.

const LATEST_VERSION: NonZeroU32

Latest supported version.

Versions 1 through LATEST_VERSION must all be supported. Support for a previous version can never be dropped.

Loading content...

Required methods

fn from_tagged_data(src: TaggedData) -> Result<Self, ProtobufError>

Convert from tagged data.

fn to_tagged_data_version(
    &self,
    version: NonZeroU32
) -> Result<TaggedData, ProtobufError>

Convert to tagged data using a specific version.

Errors

  • Returns error if version is unsupported.
  • Returns error if version is supported but is too old to represent this object.
Loading content...

Provided methods

fn to_tagged_data(&self) -> TaggedData

Convert to tagged data using the latest supported version.

The default implementation calls to_tagged_data_version with LATEST_VERSION as version number.

fn from_tagged_data_bytes(bytes: &[u8]) -> Result<Self>

Deserialize from a slice of tagged data bytes.

fn to_tagged_data_bytes(&self) -> Vec<u8>

Serialize to a vector of tagged data bytes.

fn read_from_tagged_data_file<P: AsRef<Path>>(path: P) -> Result<Self>

Read from tagged data file.

fn write_to_tagged_data_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

Write to tagged data file.

Loading content...

Implementors

impl TaggedDataRepr for UnsealedModule[src]

Loading content...