diff --git a/pw_status/docs.rst b/pw_status/docs.rst index 69560b75d..a1775989f 100644 --- a/pw_status/docs.rst +++ b/pw_status/docs.rst @@ -165,6 +165,9 @@ function that corresponds with the status code. // the authentication and try again. pw::Status::Unauthenticated() +.. note:: + Status enumerations are also supported for Python and Typescript. + .. attention:: Some code may use all-caps status values such as ``Status::UNKNOWN`` instead diff --git a/pw_status/py/pw_status/__init__.py b/pw_status/py/pw_status/__init__.py index 6d22bda82..7fcc19e98 100644 --- a/pw_status/py/pw_status/__init__.py +++ b/pw_status/py/pw_status/__init__.py @@ -25,7 +25,6 @@ class Status(enum.Enum): NOT_FOUND = 5 ALREADY_EXISTS = 6 PERMISSION_DENIED = 7 - UNAUTHENTICATED = 16 RESOURCE_EXHAUSTED = 8 FAILED_PRECONDITION = 9 ABORTED = 10 @@ -34,6 +33,7 @@ class Status(enum.Enum): INTERNAL = 13 UNAVAILABLE = 14 DATA_LOSS = 15 + UNAUTHENTICATED = 16 def ok(self) -> bool: return self is self.OK diff --git a/pw_status/ts/BUILD.bazel b/pw_status/ts/BUILD.bazel new file mode 100644 index 000000000..cee3b049c --- /dev/null +++ b/pw_status/ts/BUILD.bazel @@ -0,0 +1,24 @@ +# Copyright 2021 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +load("@npm//@bazel/typescript:index.bzl", "ts_library") + +package(default_visibility = ["//visibility:public"]) + +ts_library( + name = "pw_status", + srcs = [ + "status.ts", + ], +) diff --git a/pw_status/ts/status.ts b/pw_status/ts/status.ts new file mode 100644 index 000000000..ac0a98202 --- /dev/null +++ b/pw_status/ts/status.ts @@ -0,0 +1,35 @@ +// Copyright 2021 The Pigweed Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +/** Pigweed Status class; mirrors pw::Status. */ + +enum Status { + OK = 0, + CANCELLED = 1, + UNKNOWN = 2, + INVALID_ARGUMENT = 3, + DEADLINE_EXCEEDED = 4, + NOT_FOUND = 5, + ALREADY_EXISTS = 6, + PERMISSION_DENIED = 7, + RESOURCE_EXHAUSTED = 8, + FAILED_PRECONDITION = 9, + ABORTED = 10, + OUT_OF_RANGE = 11, + UNIMPLEMENTED = 12, + INTERNAL = 13, + UNAVAILABLE = 14, + DATA_LOSS = 15, + UNAUTHENTICATED = 16 +}