pub struct GeneratedService { /* private fields */ }Expand description
A typed generated Compose service definition.
Implementations§
Source§impl GeneratedService
impl GeneratedService
Sourcepub fn add_runtime_field(
&mut self,
field: GeneratedServiceRuntimeField,
) -> Result<(), GenerationError>
pub fn add_runtime_field( &mut self, field: GeneratedServiceRuntimeField, ) -> Result<(), GenerationError>
Adds one generated raw-preserving resource or namespace field exactly once.
All string values must be resolved single-line strings. The generated YAML is parse-back validated with the rest of the document; this method deliberately makes no provider or runtime support claim.
§Errors
Returns GenerationError::DuplicateField when the same runtime field was already
selected, or GenerationError::InvalidServiceRuntimeField when its value is not safe
for generated Compose YAML.
Sourcepub fn runtime_fields(&self) -> &[GeneratedServiceRuntimeField]
pub fn runtime_fields(&self) -> &[GeneratedServiceRuntimeField]
Returns the selected raw-preserving generated runtime fields in insertion order.
Sourcepub fn set_hostname(
&mut self,
hostname: GeneratedHostname,
) -> Result<(), GenerationError>
pub fn set_hostname( &mut self, hostname: GeneratedHostname, ) -> Result<(), GenerationError>
Sets one resolved RFC-1123 service hostname exactly once.
§Errors
Returns GenerationError::InvalidHostname for an empty, expression-shaped, non-ASCII,
overlong, or otherwise invalid hostname, or GenerationError::DuplicateField when
already configured.
Sourcepub fn set_container_name(
&mut self,
name: GeneratedString,
) -> Result<(), GenerationError>
pub fn set_container_name( &mut self, name: GeneratedString, ) -> Result<(), GenerationError>
Sets the custom runtime container name exactly once.
§Errors
Returns GenerationError::InvalidContainerName when the value does not match Compose’s
portable container-name grammar or GenerationError::DuplicateField when already
configured.
Sourcepub fn set_image(
&mut self,
image: GeneratedString,
) -> Result<(), GenerationError>
pub fn set_image( &mut self, image: GeneratedString, ) -> Result<(), GenerationError>
Sets the service image exactly once.
§Errors
Returns GenerationError::EmptyValue for an empty image or
GenerationError::DuplicateField when already configured.
Sourcepub fn set_entrypoint(
&mut self,
entrypoint: GeneratedEntrypoint,
) -> Result<(), GenerationError>
pub fn set_entrypoint( &mut self, entrypoint: GeneratedEntrypoint, ) -> Result<(), GenerationError>
Sets the Compose entrypoint form exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_command(
&mut self,
command: GeneratedCommand,
) -> Result<(), GenerationError>
pub fn set_command( &mut self, command: GeneratedCommand, ) -> Result<(), GenerationError>
Sets the Compose command form exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_init(&mut self, init: bool) -> Result<(), GenerationError>
pub fn set_init(&mut self, init: bool) -> Result<(), GenerationError>
Sets the Compose init-process choice exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_stdin_open(
&mut self,
stdin_open: bool,
) -> Result<(), GenerationError>
pub fn set_stdin_open( &mut self, stdin_open: bool, ) -> Result<(), GenerationError>
Sets the Compose standard-input-open choice exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_tty(&mut self, tty: bool) -> Result<(), GenerationError>
pub fn set_tty(&mut self, tty: bool) -> Result<(), GenerationError>
Sets the Compose terminal-allocation choice exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_privileged(
&mut self,
privileged: bool,
) -> Result<(), GenerationError>
pub fn set_privileged( &mut self, privileged: bool, ) -> Result<(), GenerationError>
Sets the Compose privileged choice exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn add_environment_file(
&mut self,
environment_file: GeneratedEnvironmentFile,
)
pub fn add_environment_file( &mut self, environment_file: GeneratedEnvironmentFile, )
Adds one ordered environment-file declaration.
Sourcepub fn add_environment(&mut self, environment: GeneratedEnvironment)
pub fn add_environment(&mut self, environment: GeneratedEnvironment)
Adds one ordered environment entry.
Sourcepub fn add_label(
&mut self,
label: GeneratedLabel,
) -> Result<(), GenerationError>
pub fn add_label( &mut self, label: GeneratedLabel, ) -> Result<(), GenerationError>
Adds one uniquely named service metadata label.
§Errors
Returns GenerationError::DuplicateName when the service already defines the label.
Sourcepub fn set_annotations(
&mut self,
annotations: Vec<GeneratedAnnotation>,
) -> Result<(), GenerationError>
pub fn set_annotations( &mut self, annotations: Vec<GeneratedAnnotation>, ) -> Result<(), GenerationError>
Sets the complete ordered mapping-form annotation collection exactly once.
Omission remains distinct from an explicit empty mapping. Names must be unique and all entries carry explicit resolved string values; key-only and null forms cannot enter this API.
§Errors
Returns GenerationError::DuplicateName for duplicate names,
GenerationError::InvalidAnnotationName or GenerationError::InvalidAnnotationValue
for unsafe values, or GenerationError::DuplicateField when already configured.
Sourcepub fn annotations(&self) -> Option<&[GeneratedAnnotation]>
pub fn annotations(&self) -> Option<&[GeneratedAnnotation]>
Returns configured annotations, distinguishing omission from an explicit empty mapping.
Sourcepub fn set_user(&mut self, user: GeneratedString) -> Result<(), GenerationError>
pub fn set_user(&mut self, user: GeneratedString) -> Result<(), GenerationError>
Sets the combined Compose user[:group] value exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_userns_mode(
&mut self,
mode: GeneratedString,
) -> Result<(), GenerationError>
pub fn set_userns_mode( &mut self, mode: GeneratedString, ) -> Result<(), GenerationError>
Sets the user-namespace mode exactly once.
§Errors
Returns GenerationError::EmptyValue for an empty mode or
GenerationError::DuplicateField when already configured.
Sourcepub fn add_supplementary_group(
&mut self,
group: GeneratedString,
) -> Result<(), GenerationError>
pub fn add_supplementary_group( &mut self, group: GeneratedString, ) -> Result<(), GenerationError>
Adds one ordered supplementary group.
§Errors
Returns GenerationError::EmptyValue for an empty group.
Sourcepub fn set_cap_add(
&mut self,
capabilities: Vec<GeneratedString>,
) -> Result<(), GenerationError>
pub fn set_cap_add( &mut self, capabilities: Vec<GeneratedString>, ) -> Result<(), GenerationError>
Sets the complete ordered cap_add sequence exactly once.
An empty vector is retained as explicit cap_add: []; never calling this method omits the
field. Values preserve exact case and ordering. No capability whitelist is applied.
§Errors
Returns GenerationError::EmptyValue for an empty item,
GenerationError::ContainsLineBreak for a carriage return or line feed,
GenerationError::DuplicateItem for an exact case-sensitive duplicate, or
GenerationError::DuplicateField when already configured. NUL bytes are rejected while
constructing GeneratedString.
Sourcepub fn cap_add(&self) -> Option<&[GeneratedString]>
pub fn cap_add(&self) -> Option<&[GeneratedString]>
Returns the configured cap_add sequence, distinguishing omission from an empty vector.
Sourcepub fn set_cap_drop(
&mut self,
capabilities: Vec<GeneratedString>,
) -> Result<(), GenerationError>
pub fn set_cap_drop( &mut self, capabilities: Vec<GeneratedString>, ) -> Result<(), GenerationError>
Sets the complete ordered cap_drop sequence exactly once.
An empty vector is retained as explicit cap_drop: []; never calling this method omits the
field. Values preserve exact case and ordering. No capability whitelist is applied.
§Errors
Returns GenerationError::EmptyValue for an empty item,
GenerationError::ContainsLineBreak for a carriage return or line feed,
GenerationError::DuplicateItem for an exact case-sensitive duplicate, or
GenerationError::DuplicateField when already configured. NUL bytes are rejected while
constructing GeneratedString.
Sourcepub fn cap_drop(&self) -> Option<&[GeneratedString]>
pub fn cap_drop(&self) -> Option<&[GeneratedString]>
Returns the configured cap_drop sequence, distinguishing omission from an empty vector.
Sourcepub fn set_devices(
&mut self,
devices: Vec<GeneratedDevice>,
) -> Result<(), GenerationError>
pub fn set_devices( &mut self, devices: Vec<GeneratedDevice>, ) -> Result<(), GenerationError>
Sets the complete ordered mixed short/long devices sequence exactly once.
An empty vector is emitted as devices: []; omission remains distinct. Exact duplicate
items and caller order are preserved. This validates only safe resolved YAML output and
does not inspect host devices, split colon triples, validate CDI, normalize permissions,
or claim runtime access.
§Errors
Rejects empty short items and empty long sources, plus NUL-bearing, multiline, or
dollar-bearing values. NUL bytes are normally rejected while constructing
GeneratedString. Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_dns(&mut self, dns: GeneratedDns) -> Result<(), GenerationError>
pub fn set_dns(&mut self, dns: GeneratedDns) -> Result<(), GenerationError>
Sets the complete scalar or ordered-list service dns form exactly once.
An empty list remains explicit. Values are retained as raw server strings: this API does not require an IP address, parse a resolver grammar, or perform network access.
§Errors
Rejects empty, multiline, NUL-bearing, or dollar-bearing values and duplicate field
configuration. NUL bytes are normally rejected while constructing GeneratedString.
Sourcepub const fn dns(&self) -> Option<&GeneratedDns>
pub const fn dns(&self) -> Option<&GeneratedDns>
Returns the configured scalar or ordered-list DNS form.
Sourcepub fn set_dns_options(
&mut self,
options: Vec<GeneratedString>,
) -> Result<(), GenerationError>
pub fn set_dns_options( &mut self, options: Vec<GeneratedString>, ) -> Result<(), GenerationError>
Sets the complete ordered service dns_opt sequence exactly once.
An empty vector remains explicit while leaving this setter unused omits the field. Values are treated as raw resolver-option strings; no option grammar or runtime behavior is inferred.
§Errors
Rejects empty, multiline, NUL-bearing, dollar-bearing, or exact-duplicate values and
duplicate field configuration. NUL bytes are normally rejected while constructing
GeneratedString.
Sourcepub fn dns_options(&self) -> Option<&[GeneratedString]>
pub fn dns_options(&self) -> Option<&[GeneratedString]>
Returns configured DNS resolver options, distinguishing omission from an empty sequence.
Sourcepub fn set_dns_search(
&mut self,
search: GeneratedDnsSearch,
) -> Result<(), GenerationError>
pub fn set_dns_search( &mut self, search: GeneratedDnsSearch, ) -> Result<(), GenerationError>
Sets the complete scalar or ordered-list service dns_search form exactly once.
An empty list remains explicit, exact duplicates and . are retained, and no domain,
resolver, provider, or runtime validation is performed.
§Errors
Rejects empty, multiline, NUL-bearing, or dollar-bearing values and duplicate field
configuration. NUL bytes are normally rejected while constructing GeneratedString.
Sourcepub const fn dns_search(&self) -> Option<&GeneratedDnsSearch>
pub const fn dns_search(&self) -> Option<&GeneratedDnsSearch>
Returns the configured scalar or ordered-list DNS search-domain form.
Sourcepub fn set_expose(
&mut self,
expose: Vec<GeneratedString>,
) -> Result<(), GenerationError>
pub fn set_expose( &mut self, expose: Vec<GeneratedString>, ) -> Result<(), GenerationError>
Sets the complete ordered service expose sequence exactly once.
An empty vector remains explicit. Every output item remains a YAML string, so number and
string identities are never silently equated. Omitted protocol and explicit /tcp remain
distinct.
§Errors
Rejects empty, deferred, multiline, NUL-bearing, malformed, SCTP, unknown-protocol, and exact-duplicate values, or duplicate field configuration.
Sourcepub fn expose(&self) -> Option<&[GeneratedString]>
pub fn expose(&self) -> Option<&[GeneratedString]>
Returns the configured exposed-port sequence, including an explicit empty sequence.
Sourcepub fn set_security_options(
&mut self,
options: Vec<GeneratedString>,
) -> Result<(), GenerationError>
pub fn set_security_options( &mut self, options: Vec<GeneratedString>, ) -> Result<(), GenerationError>
Sets the complete ordered raw service security_opt sequence exactly once.
An empty vector remains explicit, exact duplicates retain their order, and no option, profile, provider, or target-runtime normalization is performed.
§Errors
Rejects empty, deferred, multiline, or NUL-bearing values and duplicate field
configuration. NUL bytes are normally rejected while constructing GeneratedString.
Sourcepub fn security_options(&self) -> Option<&[GeneratedString]>
pub fn security_options(&self) -> Option<&[GeneratedString]>
Returns configured raw security options, distinguishing omission from an empty sequence.
Sourcepub fn devices(&self) -> Option<&[GeneratedDevice]>
pub fn devices(&self) -> Option<&[GeneratedDevice]>
Returns configured devices, distinguishing omission from an explicit empty sequence.
Sourcepub fn set_working_dir(
&mut self,
directory: GeneratedString,
) -> Result<(), GenerationError>
pub fn set_working_dir( &mut self, directory: GeneratedString, ) -> Result<(), GenerationError>
Sets the container working directory exactly once.
§Errors
Returns GenerationError::EmptyValue for an empty directory or
GenerationError::DuplicateField when already configured.
Sourcepub fn set_read_only(&mut self, read_only: bool) -> Result<(), GenerationError>
pub fn set_read_only(&mut self, read_only: bool) -> Result<(), GenerationError>
Sets the read-only-root choice exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_pids_limit(
&mut self,
limit: GeneratedPidsLimit,
) -> Result<(), GenerationError>
pub fn set_pids_limit( &mut self, limit: GeneratedPidsLimit, ) -> Result<(), GenerationError>
Sets an unlimited or positive finite service PID limit exactly once.
§Errors
Returns GenerationError::InvalidPidsLimit when a finite spelling is empty, zero,
signed, fractional, exponent-shaped, or otherwise not ASCII decimal, or
GenerationError::DuplicateField when already configured.
Sourcepub fn set_shm_size(
&mut self,
size: GeneratedShmSize,
) -> Result<(), GenerationError>
pub fn set_shm_size( &mut self, size: GeneratedShmSize, ) -> Result<(), GenerationError>
Sets one explicit positive service shared-memory size exactly once.
§Errors
Returns GenerationError::InvalidShmSize when the amount is empty, zero, has leading
zeros, a sign, fraction, exponent, whitespace, or non-ASCII digits, or
GenerationError::DuplicateField when already configured.
Sourcepub fn set_mem_limit(
&mut self,
limit: GeneratedMemLimit,
) -> Result<(), GenerationError>
pub fn set_mem_limit( &mut self, limit: GeneratedMemLimit, ) -> Result<(), GenerationError>
Sets one explicit positive service memory limit exactly once.
§Errors
Returns GenerationError::InvalidMemLimit when the amount is empty, zero, has leading
zeros, a sign, fraction, exponent, whitespace, or non-ASCII digits, or
GenerationError::DuplicateField when already configured.
Sourcepub fn set_tmpfs(
&mut self,
tmpfs: GeneratedTmpfs,
) -> Result<(), GenerationError>
pub fn set_tmpfs( &mut self, tmpfs: GeneratedTmpfs, ) -> Result<(), GenerationError>
Sets the complete scalar or list service-level tmpfs form exactly once.
An empty list is retained explicitly. Item spelling, ordering, and case remain unchanged.
§Errors
Rejects empty, multiline, deferred, or structurally malformed items. Documented mode,
uid, and gid assignments and other well-shaped raw target options remain exact, including
duplicate list entries. NUL bytes are rejected while constructing GeneratedString. Returns
GenerationError::DuplicateField when already configured.
Sourcepub const fn tmpfs(&self) -> Option<&GeneratedTmpfs>
pub const fn tmpfs(&self) -> Option<&GeneratedTmpfs>
Returns the configured scalar or list form, distinguishing omission from an empty list.
Sourcepub fn set_sysctls(
&mut self,
sysctls: GeneratedSysctls,
) -> Result<(), GenerationError>
pub fn set_sysctls( &mut self, sysctls: GeneratedSysctls, ) -> Result<(), GenerationError>
Sets the complete mapping or list sysctls form exactly once.
Empty collections remain explicit. Mapping names and list strings must be exact-unique; neither form applies namespace validation or runtime coercion.
§Errors
Rejects duplicate map names, duplicate exact list items, multiline or dollar-bearing list
items, and duplicate field configuration. NUL-bearing list items are rejected while
constructing GeneratedString.
Sourcepub const fn sysctls(&self) -> Option<&GeneratedSysctls>
pub const fn sysctls(&self) -> Option<&GeneratedSysctls>
Returns the configured form, distinguishing omission from explicit empty collections.
Sourcepub fn set_logging(
&mut self,
logging: GeneratedLogging,
) -> Result<(), GenerationError>
pub fn set_logging( &mut self, logging: GeneratedLogging, ) -> Result<(), GenerationError>
Sets explicit logging configuration exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured. Driver spelling and
option semantics are otherwise left uninterpreted.
Sourcepub const fn logging(&self) -> Option<&GeneratedLogging>
pub const fn logging(&self) -> Option<&GeneratedLogging>
Returns configured logging, distinguishing omission from explicit empty options.
Sourcepub fn set_ulimits(
&mut self,
ulimits: GeneratedUlimits,
) -> Result<(), GenerationError>
pub fn set_ulimits( &mut self, ulimits: GeneratedUlimits, ) -> Result<(), GenerationError>
Sets the complete ordered service ulimits mapping exactly once.
An empty mapping remains explicit. Values are already validated while constructing
GeneratedUlimit and names are unique by construction in GeneratedUlimits.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub const fn ulimits(&self) -> Option<&GeneratedUlimits>
pub const fn ulimits(&self) -> Option<&GeneratedUlimits>
Returns configured ordered limits, distinguishing omission from an explicit empty mapping.
Sourcepub fn set_pull_policy(
&mut self,
policy: GeneratedPullPolicy,
) -> Result<(), GenerationError>
pub fn set_pull_policy( &mut self, policy: GeneratedPullPolicy, ) -> Result<(), GenerationError>
Sets a documented service image pull policy exactly once.
§Errors
Returns GenerationError::InvalidPullPolicyDuration for an invalid custom interval or
GenerationError::DuplicateField when already configured.
Sourcepub fn set_restart(
&mut self,
restart: GeneratedRestartPolicy,
) -> Result<(), GenerationError>
pub fn set_restart( &mut self, restart: GeneratedRestartPolicy, ) -> Result<(), GenerationError>
Sets the service-level restart policy exactly once.
§Errors
Returns GenerationError::DuplicateField when already configured.
Sourcepub fn set_stop_signal(
&mut self,
signal: GeneratedString,
) -> Result<(), GenerationError>
pub fn set_stop_signal( &mut self, signal: GeneratedString, ) -> Result<(), GenerationError>
Sets the service stop signal exactly once without imposing a signal-token grammar.
§Errors
Returns GenerationError::DuplicateField when already configured. Quoted empty values
are preserved; NUL-bearing values are rejected while constructing GeneratedString.
Sourcepub fn set_stop_grace_period(
&mut self,
period: GeneratedString,
) -> Result<(), GenerationError>
pub fn set_stop_grace_period( &mut self, period: GeneratedString, ) -> Result<(), GenerationError>
Sets the raw-preserving service stop grace period exactly once.
§Errors
Returns GenerationError::InvalidStopGracePeriod when the value does not match the
ComposeLens raw-preserving duration policy or dollar-marker convention, or
GenerationError::DuplicateField when already configured.
Sourcepub fn add_extra_host(&mut self, host: GeneratedExtraHost)
pub fn add_extra_host(&mut self, host: GeneratedExtraHost)
Adds one ordered host mapping.
Sourcepub fn add_port(&mut self, port: GeneratedPort)
pub fn add_port(&mut self, port: GeneratedPort)
Adds one ordered published-port declaration.
Sourcepub fn add_mount(&mut self, mount: GeneratedMount)
pub fn add_mount(&mut self, mount: GeneratedMount)
Adds one ordered mount.
Sourcepub fn add_network(
&mut self,
network: GeneratedNetworkAttachment,
) -> Result<(), GenerationError>
pub fn add_network( &mut self, network: GeneratedNetworkAttachment, ) -> Result<(), GenerationError>
Adds one uniquely named network attachment.
§Errors
Returns GenerationError::DuplicateName when the service already uses the network.
Trait Implementations§
Source§impl Clone for GeneratedService
impl Clone for GeneratedService
Source§fn clone(&self) -> GeneratedService
fn clone(&self) -> GeneratedService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more