Skip to main content

GeneratedService

Struct GeneratedService 

Source
pub struct GeneratedService { /* private fields */ }
Expand description

A typed generated Compose service definition.

Implementations§

Source§

impl GeneratedService

Source

pub fn new(name: impl Into<String>) -> Result<Self, GenerationError>

Creates an empty service with a validated name.

§Errors

Rejects an empty or NUL-bearing name.

Source

pub fn name(&self) -> &str

Returns the service name.

Source

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.

Source

pub fn runtime_fields(&self) -> &[GeneratedServiceRuntimeField]

Returns the selected raw-preserving generated runtime fields in insertion order.

Source

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.

Source

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.

Source

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.

Source

pub fn set_entrypoint( &mut self, entrypoint: GeneratedEntrypoint, ) -> Result<(), GenerationError>

Sets the Compose entrypoint form exactly once.

§Errors

Returns GenerationError::DuplicateField when already configured.

Source

pub fn set_command( &mut self, command: GeneratedCommand, ) -> Result<(), GenerationError>

Sets the Compose command form exactly once.

§Errors

Returns GenerationError::DuplicateField when already configured.

Source

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.

Source

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.

Source

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.

Source

pub fn set_privileged( &mut self, privileged: bool, ) -> Result<(), GenerationError>

Sets the Compose privileged choice exactly once.

§Errors

Returns GenerationError::DuplicateField when already configured.

Source

pub fn add_environment_file( &mut self, environment_file: GeneratedEnvironmentFile, )

Adds one ordered environment-file declaration.

Source

pub fn add_environment(&mut self, environment: GeneratedEnvironment)

Adds one ordered environment entry.

Source

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.

Source

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.

Source

pub fn annotations(&self) -> Option<&[GeneratedAnnotation]>

Returns configured annotations, distinguishing omission from an explicit empty mapping.

Source

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.

Source

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.

Source

pub fn add_supplementary_group( &mut self, group: GeneratedString, ) -> Result<(), GenerationError>

Adds one ordered supplementary group.

§Errors

Returns GenerationError::EmptyValue for an empty group.

Source

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.

Source

pub fn cap_add(&self) -> Option<&[GeneratedString]>

Returns the configured cap_add sequence, distinguishing omission from an empty vector.

Source

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.

Source

pub fn cap_drop(&self) -> Option<&[GeneratedString]>

Returns the configured cap_drop sequence, distinguishing omission from an empty vector.

Source

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.

Source

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.

Source

pub const fn dns(&self) -> Option<&GeneratedDns>

Returns the configured scalar or ordered-list DNS form.

Source

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.

Source

pub fn dns_options(&self) -> Option<&[GeneratedString]>

Returns configured DNS resolver options, distinguishing omission from an empty sequence.

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.

Returns the configured scalar or ordered-list DNS search-domain form.

Source

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.

Source

pub fn expose(&self) -> Option<&[GeneratedString]>

Returns the configured exposed-port sequence, including an explicit empty sequence.

Source

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.

Source

pub fn security_options(&self) -> Option<&[GeneratedString]>

Returns configured raw security options, distinguishing omission from an empty sequence.

Source

pub fn devices(&self) -> Option<&[GeneratedDevice]>

Returns configured devices, distinguishing omission from an explicit empty sequence.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn tmpfs(&self) -> Option<&GeneratedTmpfs>

Returns the configured scalar or list form, distinguishing omission from an empty list.

Source

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.

Source

pub const fn sysctls(&self) -> Option<&GeneratedSysctls>

Returns the configured form, distinguishing omission from explicit empty collections.

Source

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.

Source

pub const fn logging(&self) -> Option<&GeneratedLogging>

Returns configured logging, distinguishing omission from explicit empty options.

Source

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.

Source

pub const fn ulimits(&self) -> Option<&GeneratedUlimits>

Returns configured ordered limits, distinguishing omission from an explicit empty mapping.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn add_extra_host(&mut self, host: GeneratedExtraHost)

Adds one ordered host mapping.

Source

pub fn add_port(&mut self, port: GeneratedPort)

Adds one ordered published-port declaration.

Source

pub fn add_mount(&mut self, mount: GeneratedMount)

Adds one ordered mount.

Source

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

Source§

fn clone(&self) -> GeneratedService

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GeneratedService

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for GeneratedService

Source§

impl PartialEq for GeneratedService

Source§

fn eq(&self, other: &GeneratedService) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GeneratedService

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.