ComponentValue Struct
A value of the component model, converted from or to the memory of a component by the canonical ABI. The values are immutable; their interpretation depends on their type: a record and a tuple are the values of their fields, a variant, an enum, an option and a result are a case (a label and an optional payload).
public readonly struct ComponentValue : IEquatable<ComponentValue>- Implements
Properties
| Name | Description |
|---|---|
| CaseName | Gets the label of a case of a variant, an enum, an option or a result. |
| Kind | Gets the kind of the value. |
| NoneValue | Gets the none case of an option. |
| Payload | Gets the payload of a case, or null. |
CaseName
ComponentValue.csNoneValue
ComponentValue.csPayload
ComponentValue.csMethods
| Name | Description |
|---|---|
| AsBool() | Returns the value of a bool. |
| AsBytes() | Returns the bytes of a list of u8. |
| AsChar() | Returns the value of a char. |
| AsErrorContext() | Returns the error-context. |
| AsF32() | Returns the value of an f32. |
| AsF64() | Returns the value of an f64. |
| AsFlags() | Returns the set labels of a flags value. |
| AsFutureReader() | Returns the readable end of a future, which the host reads. |
| AsList() | Returns the elements of a list. |
| AsRecord() | Returns the values of the fields of a record or a tuple. |
| AsResource() | Returns the resource of a handle. |
| AsS16() | Returns the value of an s16. |
| AsS32() | Returns the value of an s32. |
| AsS64() | Returns the value of an s64. |
| AsS8() | Returns the value of an s8. |
| AsStreamReader() | Returns the readable end of a stream, which the host reads. |
| AsString() | Returns the value of a string. |
| AsU16() | Returns the value of a u16. |
| AsU32() | Returns the value of a u32. |
| AsU64() | Returns the value of a u64. |
| AsU8() | Returns the value of a u8. |
| Equals(ComponentValue) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Indicates whether this instance and a specified object are equal. |
| Error(ComponentValue?) | Creates the error case of a result. |
| FromBool(bool) | Creates a bool. |
| FromBytes(ReadOnlySpan<byte>) | Creates a list of u8 from bytes, which are copied. |
| FromCase(string, ComponentValue?) | Creates a case of a variant, an enum, an option or a result. |
| FromChar(Rune) | Creates a char. |
| FromEnum(string) | Creates a case of an enum. |
| FromErrorContext(ComponentErrorContext) | Creates an error-context. |
| FromF32(float) | Creates an f32. |
| FromF64(double) | Creates an f64. |
| FromFlags(IEnumerable<string>) | Creates a flags value from the set labels. |
| FromList(IEnumerable<ComponentValue>) | Creates a list. |
| FromOption(ComponentValue?) | Creates an option: some with the value, or none. |
| FromRecord(ReadOnlySpan<ComponentValue>) | Creates a record or a tuple from the values of its fields, in the order of the type. |
| FromResource(ComponentResource) | Creates a handle to a resource, for an own or a borrow type. |
| FromS16(short) | Creates an s16. |
| FromS32(int) | Creates an s32. |
| FromS64(long) | Creates an s64. |
| FromS8(sbyte) | Creates an s8. |
| FromString(string) | Creates a string. A string with an unpaired surrogate cannot be given to a component. |
| FromTuple(ReadOnlySpan<ComponentValue>) | Creates a tuple from the values of its fields. |
| FromU16(ushort) | Creates a u16. |
| FromU32(uint) | Creates a u32. |
| FromU64(ulong) | Creates a u64. |
| FromU8(byte) | Creates a u8. |
| GetHashCode() | Returns the hash code for this instance. |
| IsCase(string) | Returns whether the value is the case name. |
| Ok(ComponentValue?) | Creates the ok case of a result. |
| Some(ComponentValue) | Creates the some case of an option. |
| ToString() | Returns the value in a form similar to the text format. |
AsBool()
ComponentValue.csAsBytes()
ComponentValue.csAsChar()
ComponentValue.csAsErrorContext()
ComponentValue.csAsF32()
ComponentValue.csAsF64()
ComponentValue.csAsFlags()
ComponentValue.csAsFutureReader()
ComponentValue.csReturns the readable end of a future, which the host reads.
public ComponentFutureReader AsFutureReader()Returns
AsList()
ComponentValue.csReturns the elements of a list.
public IReadOnlyList<ComponentValue> AsList()AsRecord()
ComponentValue.csReturns the values of the fields of a record or a tuple.
public IReadOnlyList<ComponentValue> AsRecord()AsResource()
ComponentValue.csAsS16()
ComponentValue.csAsS32()
ComponentValue.csAsS64()
ComponentValue.csAsS8()
ComponentValue.csAsStreamReader()
ComponentValue.csReturns the readable end of a stream, which the host reads.
public ComponentStreamReader AsStreamReader()Returns
AsString()
ComponentValue.csAsU16()
ComponentValue.csAsU32()
ComponentValue.csAsU64()
ComponentValue.csAsU8()
ComponentValue.csEquals overloads
Equals(ComponentValue)
ComponentValue.csIndicates whether the current object is equal to another object of the same type.
public bool Equals(ComponentValue other)Parameters
otherComponentValue- An object to compare with this object.
Returns
bool true if the current object is equal to the other parameter; otherwise, false.
Equals(object?)
ComponentValue.csError(ComponentValue?)
ComponentValue.csCreates the error case of a result.
public static ComponentValue Error(ComponentValue? value = null)FromBool(bool)
ComponentValue.csCreates a bool.
public static ComponentValue FromBool(bool value)FromBytes(ReadOnlySpan<byte>)
ComponentValue.csCreates a list of u8 from bytes, which are copied.
public static ComponentValue FromBytes(ReadOnlySpan<byte> bytes)FromCase(string, ComponentValue?)
ComponentValue.csCreates a case of a variant, an enum, an option or a result.
public static ComponentValue FromCase(string name, ComponentValue? payload = null)Parameters
namestring- The label of the case.
payloadComponentValue?- The payload of the case, or null.
Returns
FromChar(Rune)
ComponentValue.csCreates a char.
public static ComponentValue FromChar(Rune value)FromEnum(string)
ComponentValue.csCreates a case of an enum.
public static ComponentValue FromEnum(string name)FromErrorContext(ComponentErrorContext)
ComponentValue.csCreates an error-context.
public static ComponentValue FromErrorContext(ComponentErrorContext errorContext)FromF32(float)
ComponentValue.csCreates an f32.
public static ComponentValue FromF32(float value)FromF64(double)
ComponentValue.csCreates an f64.
public static ComponentValue FromF64(double value)FromFlags(IEnumerable<string>)
ComponentValue.csCreates a flags value from the set labels.
public static ComponentValue FromFlags(IEnumerable<string> labels)FromList(IEnumerable<ComponentValue>)
ComponentValue.csCreates a list.
public static ComponentValue FromList(IEnumerable<ComponentValue> values)FromOption(ComponentValue?)
ComponentValue.csCreates an option: some with the value, or none.
public static ComponentValue FromOption(ComponentValue? value)FromRecord(ReadOnlySpan<ComponentValue>)
ComponentValue.csCreates a record or a tuple from the values of its fields, in the order of the type.
public static ComponentValue FromRecord(params scoped ReadOnlySpan<ComponentValue> fields)FromResource(ComponentResource)
ComponentValue.csCreates a handle to a resource, for an own or a borrow type.
public static ComponentValue FromResource(ComponentResource resource)FromS16(short)
ComponentValue.csCreates an s16.
public static ComponentValue FromS16(short value)FromS32(int)
ComponentValue.csCreates an s32.
public static ComponentValue FromS32(int value)FromS64(long)
ComponentValue.csCreates an s64.
public static ComponentValue FromS64(long value)FromS8(sbyte)
ComponentValue.csCreates an s8.
public static ComponentValue FromS8(sbyte value)FromString(string)
ComponentValue.csCreates a string. A string with an unpaired surrogate cannot be given to a component.
public static ComponentValue FromString(string value)FromTuple(ReadOnlySpan<ComponentValue>)
ComponentValue.csCreates a tuple from the values of its fields.
public static ComponentValue FromTuple(params scoped ReadOnlySpan<ComponentValue> fields)FromU16(ushort)
ComponentValue.csCreates a u16.
public static ComponentValue FromU16(ushort value)FromU32(uint)
ComponentValue.csCreates a u32.
public static ComponentValue FromU32(uint value)FromU64(ulong)
ComponentValue.csCreates a u64.
public static ComponentValue FromU64(ulong value)FromU8(byte)
ComponentValue.csCreates a u8.
public static ComponentValue FromU8(byte value)GetHashCode()
ComponentValue.csIsCase(string)
ComponentValue.csOk(ComponentValue?)
ComponentValue.csCreates the ok case of a result.
public static ComponentValue Ok(ComponentValue? value = null)Some(ComponentValue)
ComponentValue.csCreates the some case of an option.
public static ComponentValue Some(ComponentValue value)ToString()
ComponentValue.csOperators
| Name | Description |
|---|---|
| operator ==(ComponentValue, ComponentValue) | Indicates whether two values are equal. |
| operator !=(ComponentValue, ComponentValue) | Indicates whether two values are not equal. |
operator ==(ComponentValue, ComponentValue)
ComponentValue.csIndicates whether two values are equal.
public static bool operator ==(ComponentValue left, ComponentValue right)operator !=(ComponentValue, ComponentValue)
ComponentValue.csIndicates whether two values are not equal.
public static bool operator !=(ComponentValue left, ComponentValue right)