pub trait BackendBuffer<T>:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn backend_family(&self) -> &'static str;
fn len(&self) -> usize;
fn as_any(&self) -> &dyn Any;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn allocation_domain(&self) -> Option<AllocationDomainId> { ... }
fn allocation_id(&self) -> Option<AllocationId> { ... }
fn map_read(&self) -> Result<HostReadGuard<'_, T>, HostAccessError> { ... }
fn map_write(&self) -> Result<HostWriteGuard<'_, T>, HostAccessError> { ... }
}Expand description
Opaque backend-owned tensor buffer.
Tensor core never inspects backend-native allocations directly. Backend crates store their own concrete handle types behind this trait and downcast inside the owning backend only.
§Examples
use std::sync::Arc;
use tenferro_tensor::{BackendBuffer, BufferHandle};
let buffer: Arc<dyn BackendBuffer<f64>> = Arc::new(BufferHandle::<f64>::new_with_len(7, 2));
assert_eq!(buffer.backend_family(), "opaque");
assert_eq!(buffer.len(), 2);Required Methods§
Sourcefn backend_family(&self) -> &'static str
fn backend_family(&self) -> &'static str
Stable backend family identifier.
Provided Methods§
Sourcefn allocation_domain(&self) -> Option<AllocationDomainId>
fn allocation_domain(&self) -> Option<AllocationDomainId>
Return the shared-allocation domain, when this buffer belongs to one.
Sourcefn allocation_id(&self) -> Option<AllocationId>
fn allocation_id(&self) -> Option<AllocationId>
Return the stable physical allocation identity, when available.
Sourcefn map_read(&self) -> Result<HostReadGuard<'_, T>, HostAccessError>
fn map_read(&self) -> Result<HostReadGuard<'_, T>, HostAccessError>
Map the allocation for closure-scoped host reads.
§Errors
The default returns HostAccessError::Unsupported. Host-visible
backends return typed overlap, pending-GPU, or backend mapping failures.
Sourcefn map_write(&self) -> Result<HostWriteGuard<'_, T>, HostAccessError>
fn map_write(&self) -> Result<HostWriteGuard<'_, T>, HostAccessError>
Map the allocation for closure-scoped host writes.
§Errors
The default returns HostAccessError::Unsupported. Host-visible
backends return typed overlap, pending-GPU, or backend mapping failures.