Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
symbian Namespace Reference

Namespaces

namespace  agent
 
namespace  analysis
 
namespace  api
 
namespace  concurrency
 
namespace  device
 
namespace  e32
 
namespace  emulator
 
namespace  http
 
namespace  native_error
 
namespace  net
 
namespace  sdk
 
namespace  sis
 
namespace  utf8
 
namespace  websocket
 

Functions

absl::Status StatusFromNativeError (int native_code, absl::string_view operation)
 
int NativeErrorFromStatus (const absl::Status &status)
 
absl::StatusOr< Json > ParseJson (std::string_view encoded, std::string_view what)
 Parses JSON text, or explains why it is not JSON.
 
bool IsValidUtf8 (std::string_view text)
 Whether text is valid UTF-8.
 
const Json * FindUnencodableString (const Json &value)
 
absl::StatusOr< std::string > DumpJson (const Json &value, std::string_view what)
 
std::string DumpJsonLossy (const Json &value)
 
absl::StatusOr< std::string > PackMsgpack (const Json &value, std::string_view what)
 
absl::StatusOr< Json > UnpackMsgpack (std::string_view encoded, std::string_view what)
 Decodes MessagePack bytes, or explains why they are not.
 
const nlohmann::json * FindUnencodableString (const nlohmann::json &value)
 The first string inside value that is not valid UTF-8, or nullptr.
 
absl::StatusOr< std::string > DumpJson (const nlohmann::json &value, std::string_view what)
 Serializes value, rejecting strings that are not valid UTF-8.
 
std::string DumpJsonLossy (const nlohmann::json &value)
 Serializes value, replacing anything that is not valid UTF-8.
 
absl::StatusOr< std::string > PackMsgpack (const nlohmann::json &value, std::string_view what)
 Encodes value as MessagePack, or says why it cannot be.
 
absl::StatusCode StatusCodeFromHttp (int http_code)
 Maps an HTTP status code to a canonical status code.
 
int StatusCodeToHttp (absl::StatusCode code)
 Maps a canonical status code to its HTTP status code.
 
absl::StatusCode StatusCodeFromWebSocket (std::uint16_t close_code)
 Maps a WebSocket close code to a canonical status code.
 
std::uint16_t StatusCodeToWebSocket (absl::StatusCode code)
 Maps a canonical status code to its WebSocket close code.
 
absl::Status MakeStatus (absl::StatusCode code, const std::string &message, const nlohmann::json &details)
 Builds a status carrying an A11 structured-details payload.
 
nlohmann::json StatusDetails (const absl::Status &status)
 Extracts the structured-details payload from a status.
 
absl::StatusOr< nlohmann::json > StatusToJson (const absl::Status &status)
 Serializes a status (code, message, details) to JSON.
 
nlohmann::json StatusToJsonOrEmptyDetails (const absl::Status &status)
 Serializes a status to JSON, never failing.
 
absl::StatusOr< absl::Status > StatusFromJson (const nlohmann::json &value)
 Reconstructs a status from its JSON representation.
 

Variables

constexpr absl::string_view kNativeErrorPayload
 
constexpr std::string_view kStatusDetailsPayloadUrl
 Type URL identifying A11's status-details payload.
 

Function Documentation

◆ DumpJson() [1/2]

absl::StatusOr< std::string > symbian::DumpJson ( const Json &  value,
std::string_view  what 
)

◆ DumpJson() [2/2]

absl::StatusOr< std::string > symbian::DumpJson ( const nlohmann::json &  value,
std::string_view  what 
)

Serializes value, rejecting strings that are not valid UTF-8.

Strict on purpose: JSON is defined over text, and a chunk holding arbitrary bytes has to be encoded (base64, as data/json.cc does) rather than smuggled into a string field where a peer's parser would reject it. This is the one caller of nlohmann that wants the error rather than a replacement character.

String values and object keys are checked before invoking nlohmann's strict serializer, including in native tests compiled without exceptions.

◆ DumpJsonLossy() [1/2]

std::string symbian::DumpJsonLossy ( const Json &  value)

◆ DumpJsonLossy() [2/2]

std::string symbian::DumpJsonLossy ( const nlohmann::json &  value)

Serializes value, replacing anything that is not valid UTF-8.

For a log line or a span attribute, where a lost byte is better than a lost message and there is no peer to reject it.

◆ FindUnencodableString() [1/2]

const Json * symbian::FindUnencodableString ( const Json &  value)

◆ FindUnencodableString() [2/2]

const nlohmann::json * symbian::FindUnencodableString ( const nlohmann::json &  value)

The first string inside value that is not valid UTF-8, or nullptr.

The strings that come from outside are not only at the top level: a response header's value and a directory entry's name are both fields of a record, and both are exactly where something outside this process can put arbitrary bytes.

Iterative, not recursive: this runs on whatever fiber is serializing, and A11's fiber stacks are fixed and small, so the depth of the document must not decide how much stack the check needs.

◆ IsValidUtf8()

bool symbian::IsValidUtf8 ( std::string_view  text)

Whether text is valid UTF-8.

Public because the answer has to be available before nlohmann is asked. See DumpJson for why asking nlohmann is not safe.

Strict by the definition every other A11 language's string type enforces, which is stricter than "the bytes are shaped like UTF-8": overlong encodings, surrogate halves and anything above U+10FFFF are all rejected. Python's bytes.decode("utf-8"), Kotlin's String(bytes) and JavaScript's TextDecoder with fatal all refuse them, so a chunk carrying them is one a peer cannot read – and a value this side refuses to write is a much better outcome than a session that dies one hop away.

◆ MakeStatus()

absl::Status symbian::MakeStatus ( absl::StatusCode  code,
const std::string &  message,
const nlohmann::json &  details 
)

Builds a status carrying an A11 structured-details payload.

The details JSON is attached to the returned absl::Status so it survives the JSON and MessagePack bridges used across the wire.

Parameters
codeCanonical status code (use kOk for success).
messageHuman-readable message.
detailsArbitrary structured detail payload.
Returns
A status combining code, message and details.

◆ NativeErrorFromStatus()

int symbian::NativeErrorFromStatus ( const absl::Status &  status)
inline

◆ PackMsgpack() [1/2]

absl::StatusOr< std::string > symbian::PackMsgpack ( const Json &  value,
std::string_view  what 
)

◆ PackMsgpack() [2/2]

absl::StatusOr< std::string > symbian::PackMsgpack ( const nlohmann::json &  value,
std::string_view  what 
)

Encodes value as MessagePack, or says why it cannot be.

◆ ParseJson()

absl::StatusOr< nlohmann::json > symbian::ParseJson ( std::string_view  encoded,
std::string_view  what 
)

Parses JSON text, or explains why it is not JSON.

Parameters
encodedJSON text to parse.
whatNames the document in the error, e.g. "WireMessage JSON".

◆ StatusCodeFromHttp()

absl::StatusCode symbian::StatusCodeFromHttp ( int  http_code)

Maps an HTTP status code to a canonical status code.

Parameters
http_codeHTTP status code.
Returns
The corresponding absl::StatusCode; unknown codes map to kUnknown rather than an invented status.

◆ StatusCodeFromWebSocket()

absl::StatusCode symbian::StatusCodeFromWebSocket ( std::uint16_t  close_code)

Maps a WebSocket close code to a canonical status code.

Parameters
close_codeWebSocket close code.
Returns
The corresponding absl::StatusCode; unknown codes map to kUnknown.

◆ StatusCodeToHttp()

int symbian::StatusCodeToHttp ( absl::StatusCode  code)

Maps a canonical status code to its HTTP status code.

Parameters
codeCanonical status code.
Returns
The corresponding HTTP status code.

◆ StatusCodeToWebSocket()

std::uint16_t symbian::StatusCodeToWebSocket ( absl::StatusCode  code)

Maps a canonical status code to its WebSocket close code.

Parameters
codeCanonical status code.
Returns
The corresponding WebSocket close code.

◆ StatusDetails()

nlohmann::json symbian::StatusDetails ( const absl::Status &  status)

Extracts the structured-details payload from a status.

Parameters
statusStatus to inspect.
Returns
The attached details JSON, or a null/empty value when none is set.

◆ StatusFromJson()

absl::StatusOr< absl::Status > symbian::StatusFromJson ( const nlohmann::json &  value)

Reconstructs a status from its JSON representation.

Parameters
valueJSON produced by StatusToJson.
Returns
The reconstructed status, or an error status when value is not a valid Status document.

◆ StatusFromNativeError()

absl::Status symbian::StatusFromNativeError ( int  native_code,
absl::string_view  operation 
)
inline

◆ StatusToJson()

absl::StatusOr< nlohmann::json > symbian::StatusToJson ( const absl::Status &  status)

Serializes a status (code, message, details) to JSON.

Parameters
statusStatus to serialize.
Returns
The JSON representation, or an error status on failure.

◆ StatusToJsonOrEmptyDetails()

nlohmann::json symbian::StatusToJsonOrEmptyDetails ( const absl::Status &  status)

Serializes a status to JSON, never failing.

For diagnostics that embed a status in a larger document and have nothing useful to do with an encoding failure. Falls back to the same fields with empty details, so the layout is the one StatusToJson produces either way.

Parameters
statusStatus to serialize.
Returns
The JSON representation.

◆ UnpackMsgpack()

absl::StatusOr< nlohmann::json > symbian::UnpackMsgpack ( std::string_view  encoded,
std::string_view  what 
)

Decodes MessagePack bytes, or explains why they are not.

Variable Documentation

◆ kNativeErrorPayload

constexpr absl::string_view symbian::kNativeErrorPayload
inlineconstexpr
Initial value:
=
"symbian.sdk/native-error"

◆ kStatusDetailsPayloadUrl

constexpr std::string_view symbian::kStatusDetailsPayloadUrl
constexpr
Initial value:
=
"type.a11.dev/status-details+json"

Type URL identifying A11's status-details payload.