Skip to main content

UniversalPlatform

Struct UniversalPlatform 

Source
pub struct UniversalPlatform { /* private fields */ }
Expand description

Universal platform implementation for generic FPGA management.

This struct provides a platform implementation that works with any FPGA device using the standard Linux FPGA subsystem. It uses lazy initialization to create FPGA and overlay handler instances on first access, ensuring efficient resource usage.

The #[platform] macro automatically registers this platform with the compatibility string “universal”, making it available as a fallback for devices without specific platform support.

§Fields

  • fpga - Lazily initialized FPGA device instance
  • overlay_handler - Lazily initialized overlay handler instance

§Thread Safety

This struct is thread-safe thanks to OnceLock, which ensures that initialization happens exactly once even with concurrent access.

Implementations§

Source§

impl UniversalPlatform

Source

pub fn new() -> Self

Create a new Universal platform instance.

Creates an empty platform with uninitialized FPGA and overlay handler instances. The actual components will be lazily initialized on first access through the Platform trait methods.

§Returns: Self
  • New UniversalPlatform instance ready for use
§Examples
use crate::platforms::universal::UniversalPlatform;

let platform = platform_for_known_platform("universal")?;

Trait Implementations§

Source§

impl Debug for UniversalPlatform

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UniversalPlatform

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Platform for UniversalPlatform

Source§

fn fpga(&self, device_handle: &str) -> Result<&dyn Fpga, FpgadError>

Get or initialize the FPGA device instance.

Returns a reference to the UniversalFPGA instance for the specified device. On first call, this creates and initializes the FPGA instance. Subsequent calls return the same cached instance.

§Arguments
  • device_handle - The device handle (e.g., “fpga0”)
§Returns: Result<&dyn Fpga, FpgadError>
  • Ok(&dyn Fpga) - Reference to the FPGA device instance
§Note

This implementation currently never returns an error, but the Result type is required by the Platform trait to support platform-specific validation.

Source§

fn overlay_handler( &self, overlay_handle: &str, ) -> Result<&dyn OverlayHandler, FpgadError>

Get or initialize the overlay handler instance.

Returns a reference to the UniversalOverlayHandler instance for the specified overlay. On first call, this creates and initializes the handler. This method also validates that the configfs overlay directory exists.

§Arguments
  • overlay_handle - The overlay handle (directory name in configfs)
§Returns: Result<&dyn OverlayHandler, FpgadError>
  • Ok(&dyn OverlayHandler) - Reference to the overlay handler instance
  • Err(FpgadError::Argument) - Overlay path has no parent or parent doesn’t exist
§Implementation Note

This method includes a workaround for the unstable get_or_try_init feature. Once that feature is stable, the error handling can be improved. See: https://github.com/rust-lang/rust/issues/121641

Source§

fn status_message(&self) -> Result<String, FpgadError>

Get a formatted status message for this platform. Read more
Source§

fn platform_compat_string(&self) -> String

Get the platform compatibility string. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more