[−][src]Enum tydi::logical::LogicalStreamType
Types of logical streams.
This structure is at the heart of the logical stream specification. It is used both to specify the type of a logical stream and internally for the process of lowering the recursive structure down to physical streams and signals.
The logical stream type is defined recursively by means of a number of stream types. Two classes of stream types are defined: stream-manipulating types, and element-manipulating types.
Examples
Variants
The Null stream type indicates the transferrence of one-valued data: it is only valid value is ∅ (null).
Bits(Positive)
The Bits stream type, defined as Bits(b)
, indicates the transferrence
of 2^b
-valued data carried by means of a group of b
bits, whereb
is a positive integer.
Group(Group)
The Group stream type acts as a product type (composition).
Union(Union)
The Union stream type acts as a sum type (exclusive disjunction).
Stream(Stream)
The Stream type is used to define a new physical stream.
Methods
impl LogicalStreamType
[src]
pub fn try_new_bits(bit_count: NonNegative) -> Result<Self>
[src]
Returns a new Bits stream type with the provided bit count as number of bits. Returns an error when the bit count is zero.
Examples
use tydi::{Error, logical::LogicalStreamType, Positive}; let bits = LogicalStreamType::try_new_bits(4); let zero = LogicalStreamType::try_new_bits(0); assert_eq!(bits, Ok(LogicalStreamType::Bits(Positive::new(4).unwrap()))); assert_eq!(zero, Err(Error::InvalidArgument("bit count cannot be zero".to_string())));
pub fn try_new_group(
group: impl IntoIterator<Item = (impl TryInto<Name, Error = impl Into<Box<dyn Error>>>, impl TryInto<LogicalStreamType, Error = impl Into<Box<dyn Error>>>)>
) -> Result<Self>
[src]
group: impl IntoIterator<Item = (impl TryInto<Name, Error = impl Into<Box<dyn Error>>>, impl TryInto<LogicalStreamType, Error = impl Into<Box<dyn Error>>>)>
) -> Result<Self>
Returns a new Group stream type from the provided iterator of names and
stream types. Returns an error when the values cannot be converted into
valid names, or valid logical stream types as required by Group
.
Examples
use tydi::{Error, logical::{Group, LogicalStreamType}}; let group = LogicalStreamType::try_new_group( vec![ ("a", 4), // TryFrom<NonNegative> for LogicalStreamType::Bits. ("b", 12), ] )?; assert!(match group { LogicalStreamType::Group(_) => true, _ => false, }); assert_eq!( LogicalStreamType::try_new_group(vec![("1badname", 4)]), Err(Error::InvalidArgument("name cannot start with a digit".to_string())) ); assert_eq!( LogicalStreamType::try_new_group(vec![("good_name", 0)]), Err(Error::InvalidArgument("bit count cannot be zero".to_string())) );
pub fn try_new_union(
union: impl IntoIterator<Item = (impl TryInto<Name, Error = impl Into<Box<dyn Error>>>, impl TryInto<LogicalStreamType, Error = impl Into<Box<dyn Error>>>)>
) -> Result<Self>
[src]
union: impl IntoIterator<Item = (impl TryInto<Name, Error = impl Into<Box<dyn Error>>>, impl TryInto<LogicalStreamType, Error = impl Into<Box<dyn Error>>>)>
) -> Result<Self>
pub fn is_element_only(&self) -> bool
[src]
Returns true if this logical stream consists of only element- manipulating stream types. This recursively checks all inner stream types.
Examples
use tydi::logical::LogicalStreamType; assert!(LogicalStreamType::Null.is_element_only()); assert!(LogicalStreamType::try_new_bits(3)?.is_element_only());
pub fn is_null(&self) -> bool
[src]
Returns true if and only if this logical stream does not result in any signals.
pub fn fields(&self) -> Fields
[src]
Flattens a logical stream type consisting of Null, Bits, Group and
Union stream types into a Fields
.
pub fn synthesize(&self) -> LogicalStream
[src]
pub fn compatible(&self, other: &LogicalStreamType) -> bool
[src]
Trait Implementations
impl Clone for LogicalStreamType
[src]
fn clone(&self) -> LogicalStreamType
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for LogicalStreamType
[src]
impl From<Group> for LogicalStreamType
[src]
fn from(group: Group) -> Self
[src]
Wraps this group in a LogicalStreamType
.
impl From<NonZeroU32> for LogicalStreamType
[src]
impl From<Stream> for LogicalStreamType
[src]
fn from(stream: Stream) -> Self
[src]
Wraps this stream in a LogicalStreamType
.
impl From<Union> for LogicalStreamType
[src]
fn from(union: Union) -> Self
[src]
Wraps this union in a LogicalStreamType
.
impl PartialEq<LogicalStreamType> for LogicalStreamType
[src]
fn eq(&self, other: &LogicalStreamType) -> bool
[src]
fn ne(&self, other: &LogicalStreamType) -> bool
[src]
impl StructuralPartialEq for LogicalStreamType
[src]
impl TryFrom<u32> for LogicalStreamType
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(bit_count: NonNegative) -> Result<Self>
[src]
Returns a new Bits stream type with the provided bit count as number of bits. Returns an error when the bit count is zero.
impl Typify for LogicalStreamType
[src]
Auto Trait Implementations
impl RefUnwindSafe for LogicalStreamType
impl Send for LogicalStreamType
impl Sync for LogicalStreamType
impl Unpin for LogicalStreamType
impl UnwindSafe for LogicalStreamType
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,