Struct Storage

Source
pub struct Storage { /* private fields */ }

Implementations§

Source§

impl Storage

Source

pub fn new() -> Self

Source

pub fn get(&self, object: ObjectHandle) -> Rc<RefCell<dyn Object>>

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn close_object(&mut self, object: ObjectHandle)

Closes the given object handle.

Panics if object is neither null or a valid handle.

Source

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.

Source

pub fn free_transient_object(&mut self, object: ObjectHandle)

Destroys a transient object.

Panics if object is not a valid transient object handle.

Source

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.

Source

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

Source

pub fn copy_object_attributes( &mut self, _src: ObjectHandle, dest: ObjectHandle, ) -> TeeResult

Source

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.

Source

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.
Source

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.

Source

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.

Source

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.

Source

pub fn allocate_persistent_object_enumerator(&mut self) -> ObjectEnumHandle

Allocates a new object enumerator and returns a handle to it.

Source

pub fn free_persistent_object_enumerator( &mut self, enumerator: ObjectEnumHandle, )

Deallocates an object enumerator.

Panics if enumerator is not a valid handle.

Source

pub fn reset_persistent_object_enumerator( &mut self, enumerator: ObjectEnumHandle, )

Resets an object enumerator.

Panics if enumerator is not a valid handle.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V