Skip to content
Meshline
SDK 1.1.0 · TypeView source on GitHub

Developer guide · API index

Members on this page

Meshline.Sdk

Meshline.Models.Protocol

ProtocolModel Class

Provides protocol JSON serialization and an overridable validation entry point.

public abstract record ProtocolModel : System.Text.Json.Serialization.IJsonOnDeserialized, System.IEquatable<Meshline.Models.Protocol.ProtocolModel>

Inheritance System.Object → ProtocolModel

Derived
↳ AccountAuthenticationRequest
↳ AccountQuery
↳ AuthenticationChallenge
↳ ChannelCloseRequest
↳ ChannelEvent
↳ ChannelReadPage
↳ ChannelReadQuery
↳ ChannelReportRequest
↳ ChannelResolveQuery
↳ ChannelResolveResult
↳ ChannelSubscriptionRequest
↳ ChannelTimelineChangedNotification
↳ ContactRecord
↳ ContentEncryption
↳ ContentReference
↳ DeviceAuthenticationRequest
↳ DeviceStateChangedNotification
↳ DeviceStatePublishResponse
↳ DirectMessageReference
↳ EncryptedPayload
↳ GroupAccountsRequest
↳ GroupApplicationApproveRequest
↳ GroupApplicationChangedNotification
↳ GroupApplicationEntry
↳ GroupApplicationPage
↳ GroupCreateRequest
↳ GroupEvent
↳ GroupHistorySecret
↳ GroupInviteEntry
↳ GroupInvitePage
↳ GroupInviteQuery
↳ GroupInviteResolveResult
↳ GroupKeyEntry
↳ GroupKeyPage
↳ GroupListQuery
↳ GroupMember
↳ GroupMemberKey
↳ GroupMemberPrivateState
↳ GroupRecoveryApproveRequest
↳ GroupRecoveryChangedNotification
↳ GroupRecoveryEntry
↳ GroupRecoveryPage
↳ GroupRecoverySubmitResult
↳ GroupResolveQuery
↳ GroupRotationPrepareRequest
↳ GroupRotationPrepareResult
↳ GroupSecretBox
↳ GroupSequenceQuery
↳ GroupState
↳ GroupSubscriptionRequest
↳ GroupSyncPage
↳ GroupTimelineChangedNotification
↳ MessageBody
↳ MessageDeliveryQuery
↳ MessageDeliveryStatus
↳ MessageKeyBox
↳ MessageSendRequest
↳ MessageTimelineChangedNotification
↳ MessageTimelineEntry
↳ MessageTimelinePage
↳ MessageTimelineQuery
↳ ProfileResolveResult
↳ RelayError
↳ RelayInfo
↳ RelayLimits
↳ RpcError
↳ RpcRequest
↳ RpcResponse
↳ SequenceResult
↳ SessionCredentials
↳ TypedProtocolModel

Implements System.Text.Json.Serialization.IJsonOnDeserialized, System.IEquatable<ProtocolModel>

Remarks

Deserialization enforces JSON representation rules but does not call Validate(NetworkContext). Call the relevant model validation and verify any required external signer or authorization evidence before trusting a received document.

Properties

ProtocolModel.AdditionalProperties Property

Unknown JSON properties retained for round-tripping, with cloned values and ordinal key comparison.

public System.Collections.Immutable.ImmutableDictionary<string,System.Text.Json.JsonElement> AdditionalProperties { get; init; }

Property Value

System.Collections.Immutable.ImmutableDictionary<System.String,System.Text.Json.JsonElement>

Methods

ProtocolModel.FromJson<T>(string) Method

Deserializes protocol JSON with strict encoding, number, property, and discriminator rules.

public static T? FromJson<T>(string json)
    where T : Meshline.Models.Protocol.ProtocolModel;

Type parameters

T

The protocol model type to deserialize.

Parameters

json System.String

The protocol JSON text to deserialize.

Returns

T
The deserialized model, or null for a JSON null value.

Exceptions

System.Text.Json.JsonException
The JSON representation violates protocol serialization rules.

System.ArgumentNullException
The json argument is null.

System.NotSupportedException
The requested model or one of its members has no supported JSON deserialization representation.

Remarks

The returned model has not passed semantic or cryptographic validation. JSON null yields a null result. Invalid Unicode, duplicate properties, unsupported number representations, and excessive nesting are rejected by the protocol serializer.

ProtocolModel.ToJson() Method

Serializes the model to canonical protocol JSON with ordinal property ordering.

public string ToJson();

Returns

System.String
The canonical JSON representation of this model.

Exceptions

System.Text.Json.JsonException
The JSON representation violates protocol serialization rules.

System.NotSupportedException
The runtime model or one of its members has no supported JSON serialization representation.

Remarks

Output uses snake_case property names, canonical base64url byte strings, and ordinal object-key ordering. Serialization does not substitute for semantic or signature validation.

ProtocolModel.Validate(NetworkContext) Method

Provides the validation entry point for derived protocol models; the base implementation reports no violations.

public virtual Meshline.Validation.ProtocolViolation? Validate(Meshline.Models.NetworkContext? context=null);

Parameters

context NetworkContext

The optional network context passed to nested validation when needed; field-only validation may ignore it.

Returns

ProtocolViolation
The first detected protocol violation, or null if the implemented checks pass.