[][src]Enum tydi::logical::LogicalStreamType

pub enum LogicalStreamType {
    Null,
    Bits(Positive),
    Group(Group),
    Union(Union),
    Stream(Stream),
}

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

Reference

Variants

Null

The Null stream type indicates the transferrence of one-valued data: it is only valid value is ∅ (null).

Reference

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.

Reference

Group(Group)

The Group stream type acts as a product type (composition).

Reference

Union(Union)

The Union stream type acts as a sum type (exclusive disjunction).

Reference

Stream(Stream)

The Stream type is used to define a new physical stream.

Reference

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]

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]

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.

Reference

pub fn fields(&self) -> Fields[src]

Flattens a logical stream type consisting of Null, Bits, Group and Union stream types into a Fields.

Reference

pub fn synthesize(&self) -> LogicalStream[src]

pub fn compatible(&self, other: &LogicalStreamType) -> bool[src]

Trait Implementations

impl Clone for LogicalStreamType[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]

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]

fn user(&self, prefix: impl Into<String>) -> Option<Type>[src]

This implementation for LogicalStreamType assumes the LogicalStreamType has already been flattened through synthesize.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.