pub struct Storage { /* private fields */ }
Implementations§
Source§impl Storage
impl Storage
pub fn new() -> Self
pub fn get(&self, object: ObjectHandle) -> Rc<RefCell<dyn Object>>
Sourcepub fn get_object_info(&self, object: ObjectHandle) -> ObjectInfo
pub fn get_object_info(&self, object: ObjectHandle) -> ObjectInfo
Returns info about an open object as well of the state of its handle.
Panics if object
is not a valid handle.
Sourcepub fn restrict_object_usage(&self, object: ObjectHandle, usage: Usage)
pub fn restrict_object_usage(&self, object: ObjectHandle, usage: Usage)
Restricts the usage of an open object handle.
Panics if object
is not a valid handle.
Source§impl Storage
impl Storage
Sourcepub fn get_object_buffer_attribute(
&self,
object: ObjectHandle,
attribute_id: AttributeId,
buffer: &mut [u8],
) -> Result<usize, ErrorWithSize>
pub fn get_object_buffer_attribute( &self, object: ObjectHandle, attribute_id: AttributeId, buffer: &mut [u8], ) -> Result<usize, ErrorWithSize>
Returns the requested buffer-type attribute associated with the given object, if any. It is written to the provided buffer and the size of what is written is returned.
Returns a wrapped value of Error::ItemNotFound if the object does not have such an attribute.
Returns a wrapped value of Error::ShortBuffer if the buffer was too small to read the attribute value into, along with the length of the attribute.
Panics if object
is not a valid handle or if attribute_id
is not of
buffer type.
Sourcepub fn get_object_value_attribute(
&self,
object: ObjectHandle,
attribute_id: AttributeId,
) -> TeeResult<ValueFields>
pub fn get_object_value_attribute( &self, object: ObjectHandle, attribute_id: AttributeId, ) -> TeeResult<ValueFields>
Returns the requested value-type attribute associated with the given object, if any.
Returns Error::ItemNotFound if the object does not have such an attribute.
Panics if object
is not a valid handle or if attribute_id
is not of
value type.
Sourcepub fn close_object(&mut self, object: ObjectHandle)
pub fn close_object(&mut self, object: ObjectHandle)
Closes the given object handle.
Panics if object
is neither null or a valid handle.
Sourcepub fn allocate_transient_object(
&mut self,
object_type: Type,
max_size: u32,
) -> TeeResult<ObjectHandle>
pub fn allocate_transient_object( &mut self, object_type: Type, max_size: u32, ) -> TeeResult<ObjectHandle>
Creates a new transient object of the given type and maximum key size.
Returns Error::NotSupported if the type is unsupported or if the maximum key size is itself not a valid key size.
Sourcepub fn free_transient_object(&mut self, object: ObjectHandle)
pub fn free_transient_object(&mut self, object: ObjectHandle)
Destroys a transient object.
Panics if object
is not a valid transient object handle.
Sourcepub fn reset_transient_object(&mut self, object: ObjectHandle)
pub fn reset_transient_object(&mut self, object: ObjectHandle)
Resets a transient object back to its uninitialized state.
Panics if object
is not a valid transient object handle.
Sourcepub fn populate_transient_object(
&self,
object: ObjectHandle,
attrs: &[Attribute],
) -> TeeResult
pub fn populate_transient_object( &self, object: ObjectHandle, attrs: &[Attribute], ) -> TeeResult
Populates the key information of a transient object from a given list of attributes.
Panics if object
is not a valid transient object handle, or if
attrs
omits required attributes or includes unrelated ones.
Source§impl Storage
impl Storage
pub fn copy_object_attributes( &mut self, _src: ObjectHandle, dest: ObjectHandle, ) -> TeeResult
Sourcepub fn generate_key(
&mut self,
object: ObjectHandle,
key_size: u32,
params: &[Attribute],
) -> TeeResult
pub fn generate_key( &mut self, object: ObjectHandle, key_size: u32, params: &[Attribute], ) -> TeeResult
Generates key information on an uninitialized, transient object, given a key size and the attributes that serve as inputs to the generation process.
Panics if object
is not a valid handle to an uninitialized, transient
object, if key size is invalid or larger than the prescribed maximum,
or if a mandatory attribute is absent.
Sourcepub fn open_persistent_object(
&mut self,
storage: TeeStorage,
id: &[u8],
flags: HandleFlags,
) -> TeeResult<ObjectHandle>
pub fn open_persistent_object( &mut self, storage: TeeStorage, id: &[u8], flags: HandleFlags, ) -> TeeResult<ObjectHandle>
Opens a new handle to an existing persistent object.
Returns Error::ItemNotFound: if storage
does not correspond to a valid
storage space, or if no object with id
is found.
Returns Error::AccessConflict if any of the following hold:
- The object is currently open with DATA_ACCESS_WRITE_META;
- The object is currently open and
flags
contains DATA_ACCESS_WRITE_META - The object is currently open without DATA_ACCESS_READ_SHARE
and
flags
contains DATA_ACCESS_READ or DATA_ACCESS_READ_SHARE; - The object is currently open with DATA_ACCESS_READ_SHARE, but
flags
does not; - The object is currently open without DATA_ACCESS_WRITE_SHARE and
flags
contains DATA_ACCESS_WRITE or DATA_ACCESS_WRITE_SHARE; - The object is currently open with DATA_ACCESS_WRITE_SHARE, but
flags
does not.
Sourcepub fn create_persistent_object(
&mut self,
storage: TeeStorage,
id: &[u8],
flags: HandleFlags,
attribute_src: ObjectHandle,
initial_data: &[u8],
) -> TeeResult<ObjectHandle>
pub fn create_persistent_object( &mut self, storage: TeeStorage, id: &[u8], flags: HandleFlags, attribute_src: ObjectHandle, initial_data: &[u8], ) -> TeeResult<ObjectHandle>
Creates a persistent object and returns a handle to it. The conferred type,
usage, and attributes are given indirectly by attribute_src
; if
attribute_src
is null then the conferred type is Data.
Returns Error::ItemNotFound: if storage
does not correspond to a valid
storage spac
Returns Error::AccessConflict if the provided ID already exists but
flags
does not contain DATA_FLAG_OVERWRITE.
Sourcepub fn close_and_delete_persistent_object(
&mut self,
object: ObjectHandle,
) -> TeeResult
pub fn close_and_delete_persistent_object( &mut self, object: ObjectHandle, ) -> TeeResult
Closes the given handle to a persistent object and deletes the object.
Panics if object
is invalid or was not opened with
DATA_ACCESS_WRITE_META.
Sourcepub fn rename_persistent_object(
&mut self,
object: ObjectHandle,
new_id: &[u8],
) -> TeeResult
pub fn rename_persistent_object( &mut self, object: ObjectHandle, new_id: &[u8], ) -> TeeResult
Renames the object’s, associating it with a new identifier.
Returns Error::AccessConflict if new_id
is the ID of an existing
object.
Panics if object
is invalid or was not opened with
DATA_ACCESS_WRITE_META.
Sourcepub fn allocate_persistent_object_enumerator(&mut self) -> ObjectEnumHandle
pub fn allocate_persistent_object_enumerator(&mut self) -> ObjectEnumHandle
Allocates a new object enumerator and returns a handle to it.
Sourcepub fn free_persistent_object_enumerator(
&mut self,
enumerator: ObjectEnumHandle,
)
pub fn free_persistent_object_enumerator( &mut self, enumerator: ObjectEnumHandle, )
Deallocates an object enumerator.
Panics if enumerator
is not a valid handle.
Sourcepub fn reset_persistent_object_enumerator(
&mut self,
enumerator: ObjectEnumHandle,
)
pub fn reset_persistent_object_enumerator( &mut self, enumerator: ObjectEnumHandle, )
Resets an object enumerator.
Panics if enumerator
is not a valid handle.
Sourcepub fn start_persistent_object_enumerator(
&mut self,
enumerator: ObjectEnumHandle,
storage: TeeStorage,
) -> TeeResult
pub fn start_persistent_object_enumerator( &mut self, enumerator: ObjectEnumHandle, storage: TeeStorage, ) -> TeeResult
Starts an object enumerator’s enumeration, or resets it if already started.
Returns Error::ItemNotFound if storage
is unsupported or it there are no
objects yet created in that storage space.
Panics if enumerator
is not a valid handle.
Sourcepub fn get_next_persistent_object<'a>(
&self,
enumerator: ObjectEnumHandle,
id_buffer: &'a mut [u8],
) -> TeeResult<(ObjectInfo, &'a [u8])>
pub fn get_next_persistent_object<'a>( &self, enumerator: ObjectEnumHandle, id_buffer: &'a mut [u8], ) -> TeeResult<(ObjectInfo, &'a [u8])>
Returns the info and ID associated with the next object in the enumeration, advancing it in the process. The returns object ID is backed by the provided buffer.
Returns Error::ItemNotFound if there are no more objects left to enumerate.
Panics if enumerator
is not a valid handle.
Sourcepub fn read_object_data<'a>(
&self,
object: ObjectHandle,
buffer: &'a mut [u8],
) -> TeeResult<&'a [u8]>
pub fn read_object_data<'a>( &self, object: ObjectHandle, buffer: &'a mut [u8], ) -> TeeResult<&'a [u8]>
Tries to read as much of the object’s data stream from the handle’s current data position as can fill the provided buffer.
Panics if object
is invalid or does not have read access.
Sourcepub fn write_object_data(
&self,
object: ObjectHandle,
buffer: &[u8],
) -> TeeResult
pub fn write_object_data( &self, object: ObjectHandle, buffer: &[u8], ) -> TeeResult
Writes the provided data to the object’s data stream at the handle’s data position, advancing that position to the end of the written data.
Returns Error::AccessConflict if the object does not have write access.
Returns Error::Overflow if writing the data would advance the data position past DATA_MAX_POSITION.
Panics if object
is invalid or does not have write access.
Sourcepub fn truncate_object_data(
&self,
object: ObjectHandle,
size: usize,
) -> TeeResult
pub fn truncate_object_data( &self, object: ObjectHandle, size: usize, ) -> TeeResult
Truncates or zero-extends the object’s data stream to provided size. This does not affect any handle’s data position.
Returns Error::Overflow if size
is larger than DATA_MAX_POSITION.
Panics if object
is invalid or does not have write access.
Sourcepub fn seek_data_object(
&self,
object: ObjectHandle,
offset: isize,
whence: Whence,
) -> TeeResult
pub fn seek_data_object( &self, object: ObjectHandle, offset: isize, whence: Whence, ) -> TeeResult
Updates the handle’s data positition, seeking at an offset from a position given by a whence value. The new position saturates at 0.
Returns Error::Overflow if the would-be position exceeds DATA_MAX_POSITION.
Panics if object
is invalid.
Auto Trait Implementations§
impl Freeze for Storage
impl !RefUnwindSafe for Storage
impl !Send for Storage
impl !Sync for Storage
impl Unpin for Storage
impl !UnwindSafe for Storage
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
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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>
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>
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 more