Struct PermissionSetEncoder
pub struct PermissionSetEncoder { /* private fields */ }Expand description
Encoder for permission sets.
The PermissionSetEncoder provides stateful encoding of permission sets from
structured Permission data to binary or XML formats as defined in ECMA-335.
It handles the complete encoding process including format markers, compression,
and proper serialization of named arguments.
§Design
The encoder converts permission structures to their binary representation with:
- Format Markers: Proper format identification bytes (0x2E for binary)
- Compression: Uses compressed integers for counts and lengths
- Type Encoding: Handles all supported argument types (Boolean, Int32, String)
- Assembly Resolution: Maps permission classes to appropriate assemblies
§Usage Pattern
ⓘ
use dotscope::metadata::security::{PermissionSetEncoder, Permission, PermissionSetFormat};
let permissions = vec![/* ... */];
let mut encoder = PermissionSetEncoder::new();
let bytes = encoder.encode_permission_set(&permissions, PermissionSetFormat::BinaryLegacy)?;§Binary Format Structure
The binary format follows this structure:
1. Format marker: '.' (0x2E)
2. Permission count (compressed integer)
3. For each permission:
- Class name length (compressed integer)
- Class name (UTF-8 bytes)
- Blob length (compressed integer)
- Property count (compressed integer)
- For each property:
- Field/Property marker (0x54)
- Type byte (0x02=Boolean, 0x04=Int32, 0x0E=String)
- Property name length + UTF-8 name
- Property value (format depends on type)Implementations§
§impl PermissionSetEncoder
impl PermissionSetEncoder
pub fn new() -> Self
pub fn new() -> Self
Creates a new encoder.
Initializes a fresh encoder state with an empty buffer.
§Returns
A new PermissionSetEncoder ready to encode permission sets.
pub fn encode_permission_set(
&mut self,
permissions: &[Permission],
format: PermissionSetFormat,
) -> Result<Vec<u8>>
pub fn encode_permission_set( &mut self, permissions: &[Permission], format: PermissionSetFormat, ) -> Result<Vec<u8>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PermissionSetEncoder
impl RefUnwindSafe for PermissionSetEncoder
impl Send for PermissionSetEncoder
impl Sync for PermissionSetEncoder
impl Unpin for PermissionSetEncoder
impl UnsafeUnpin for PermissionSetEncoder
impl UnwindSafe for PermissionSetEncoder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.