Trait il2_iltags::tags::ILTag [−][src]
pub trait ILTag: Any + Send + Sync {
fn id(&self) -> u64;
fn value_size(&self) -> u64;
fn serialize_value(&self, writer: &mut dyn Writer) -> Result<()>;
fn deserialize_value(
&mut self,
factory: &dyn ILTagFactory,
value_size: usize,
reader: &mut dyn Reader
) -> Result<()>;
fn as_any(&self) -> &dyn Any;
fn as_mut_any(&mut self) -> &mut dyn Any;
fn is_implicity(&self) -> bool { ... }
fn is_reserved(&self) -> bool { ... }
fn size(&self) -> u64 { ... }
fn serialize(&self, writer: &mut dyn Writer) -> Result<()> { ... }
fn to_bytes(&self) -> Result<Vec<u8>> { ... }
}
Expand description
This trait must be implemented by all ILTags on this library. It defines the basic methods for tag identification, serialization and deserialization of values.
The actual manipulation of the information inside the tags must be handled
directly by each tag implementation by the use of std::any::Any
trait.
Required methods
fn value_size(&self) -> u64
fn value_size(&self) -> u64
Retuns the size of the serialized value in bytes.
fn serialize_value(&self, writer: &mut dyn Writer) -> Result<()>
fn serialize_value(&self, writer: &mut dyn Writer) -> Result<()>
Serializes the payload of this tag.
Arguments:
writer
: The writer that will receive the encoded value;
Returns:
Ok()
: On success.Err(())
: If the buffer is too small to hold the encoded value.
fn deserialize_value(
&mut self,
factory: &dyn ILTagFactory,
value_size: usize,
reader: &mut dyn Reader
) -> Result<()>
fn deserialize_value(
&mut self,
factory: &dyn ILTagFactory,
value_size: usize,
reader: &mut dyn Reader
) -> Result<()>
Deserializes the value.
Arguments:
factory
: The current tag factory. It is used to create new inner tags if necessary.value_size
: Size of the value in bytes;reader
: The tag reader to be used;
Returns:
Ok()
: On success.Err(())
: In case of error.
fn as_mut_any(&mut self) -> &mut dyn Any
fn as_mut_any(&mut self) -> &mut dyn Any
Returns a mutable reference as Any.
Provided methods
fn is_implicity(&self) -> bool
fn is_implicity(&self) -> bool
Verifies if this tag is implicity.
fn is_reserved(&self) -> bool
fn is_reserved(&self) -> bool
Verifies if this tag is reserved.
Serializes this tag.
Arguments:
writer
: The writer that will receive the encoded value;
Returns:
Ok()
: On success.Err(())
: If the buffer is too small to hold the encoded value.