pub struct LegacyAppPathString(/* private fields */);Expand description
A UTF-8 path for preserving raw path compatibility at the app-server API
boundary while Codex migrates to PathUri.
Supports storing arbitrary strings read from the API and converting to and
from PathUri using an explicitly selected native path convention.
When converting from PathUri, “native” refers to the supplied
PathConvention, which may be foreign to the operating system running
this process. The inner string is private so path-producing code must use a
path conversion method instead of bypassing the intended conversion
boundary. Non-UTF-8 paths are converted to UTF-8 lossily because this API
value is serialized as a JSON string.
Deserialization and Self::from_string accept any UTF-8 string without
interpreting or validating it. Use Self::from_string when a caller
already owns legacy app-server path text and needs to preserve its wire
spelling; use Self::from_path, Self::from_abs_path, or
Self::from_path_uri when converting an actual path value. Relative
path text remains valid until an operation such as Self::to_path_uri
requires an absolute path.
Implementations§
Source§impl LegacyAppPathString
impl LegacyAppPathString
Sourcepub fn from_string(path: impl Into<String>) -> Self
pub fn from_string(path: impl Into<String>) -> Self
Preserves already-legacy app-server path text without interpreting it using the current host.
This is for API-boundary values that are already strings, including
relative or foreign-platform spellings. Callers with a local
Path, AbsolutePathBuf, or PathUri should use the
corresponding typed constructor instead.
Sourcepub fn from_path(path: &Path) -> Self
pub fn from_path(path: &Path) -> Self
Preserves path text without interpreting it using the current host.
Sourcepub fn from_abs_path(path: &AbsolutePathBuf) -> Self
pub fn from_abs_path(path: &AbsolutePathBuf) -> Self
Renders an absolute path using the current host’s path convention.
Sourcepub fn from_path_uri(
path: &PathUri,
convention: PathConvention,
) -> Result<Self, LegacyAppPathStringError>
pub fn from_path_uri( path: &PathUri, convention: PathConvention, ) -> Result<Self, LegacyAppPathStringError>
Renders a path URI using the requested native path convention.
Rendering fails when the URI shape does not match the convention, such as a POSIX path rendered as Windows or a UNC path rendered as POSIX. It also fails when an opaque fallback does not encode an absolute path for the convention. Non-UTF-8 segments are rendered lossily, and encoded separators are emitted as native path text.
Sourcepub fn to_path_uri(
&self,
convention: PathConvention,
) -> Result<PathUri, LegacyAppPathStringError>
pub fn to_path_uri( &self, convention: PathConvention, ) -> Result<PathUri, LegacyAppPathStringError>
Parses this API string as an absolute path using the requested native path convention and returns its canonical path URI.
Sourcepub fn to_inferred_path_uri(&self) -> Option<PathUri>
pub fn to_inferred_path_uri(&self) -> Option<PathUri>
Parses this API string as an absolute path using the convention inferred from its spelling.
Sourcepub fn render_for_ui(&self) -> String
pub fn render_for_ui(&self) -> String
Renders this API path for display in a user interface.
Absolute paths are normalized using their inferred native convention. Strings that cannot be interpreted as absolute paths retain their raw API spelling.
Sourcepub fn to_inferred_abs_path(&self) -> Option<AbsolutePathBuf>
pub fn to_inferred_abs_path(&self) -> Option<AbsolutePathBuf>
Parses this API string as a host-native absolute path.
Sourcepub fn infer_absolute_path_convention(&self) -> Option<PathConvention>
pub fn infer_absolute_path_convention(&self) -> Option<PathConvention>
Infers the path convention of an absolute API path from its spelling.
Relative paths and ambiguous spellings return None. In particular,
slash-prefixed paths are treated as POSIX even when they could also be
interpreted as slash-delimited Windows UNC paths.
pub fn as_str(&self) -> &str
pub fn into_string(self) -> String
Trait Implementations§
Source§impl Clone for LegacyAppPathString
impl Clone for LegacyAppPathString
Source§fn clone(&self) -> LegacyAppPathString
fn clone(&self) -> LegacyAppPathString
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LegacyAppPathString
impl Debug for LegacyAppPathString
Source§impl<'de> Deserialize<'de> for LegacyAppPathString
impl<'de> Deserialize<'de> for LegacyAppPathString
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for LegacyAppPathString
impl Display for LegacyAppPathString
impl Eq for LegacyAppPathString
Source§impl From<AbsolutePathBuf> for LegacyAppPathString
impl From<AbsolutePathBuf> for LegacyAppPathString
Source§fn from(path: AbsolutePathBuf) -> Self
fn from(path: AbsolutePathBuf) -> Self
Source§impl From<PathUri> for LegacyAppPathString
impl From<PathUri> for LegacyAppPathString
Source§impl Hash for LegacyAppPathString
impl Hash for LegacyAppPathString
Source§impl JsonSchema for LegacyAppPathString
impl JsonSchema for LegacyAppPathString
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl PartialEq for LegacyAppPathString
impl PartialEq for LegacyAppPathString
Source§impl Serialize for LegacyAppPathString
impl Serialize for LegacyAppPathString
impl StructuralPartialEq for LegacyAppPathString
Source§impl TS for LegacyAppPathString
impl TS for LegacyAppPathString
Source§type WithoutGenerics = LegacyAppPathString
type WithoutGenerics = LegacyAppPathString
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or ().
The only requirement for these dummy types is that EXPORT_TO must be None. Read moreSource§type OptionInnerType = LegacyAppPathString
type OptionInnerType = LegacyAppPathString
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete() -> String
fn decl_concrete() -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl() -> String
fn decl() -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline() -> String
fn inline() -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened() -> String
fn inline_flattened() -> String
This function will panic if the type cannot be flattened.
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported.The returned path does not include the base directory from
TS_RS_EXPORT_DIR. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies() -> Vec<Dependency>where
Self: 'static,
fn dependencies() -> Vec<Dependency>where
Self: 'static,
Source§fn export() -> Result<(), ExportError>where
Self: 'static,
fn export() -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all() -> Result<(), ExportError>where
Self: 'static,
fn export_all() -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use
TS::export. Read moreSource§fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use
TS::export. Read more